Link to home
Start Free TrialLog in
Avatar of iceman19330
iceman19330

asked on

Issue on Javascript Onclick function

I am having an issue inserting links into an image gallery - I want the large image to be clickable.  If I use anchor links the gallery breaks so I was trying to use an onClick but for whatever reason the alert I pop up on the click always has the last image reference in it.

Not sure what I am doing wrong.

You can see it here:  http://goo.gl/4attfM
Avatar of Gary
Gary
Flag of Ireland image

Because the last image is actually on top, you are just setting the opacity to 0
jQuery solution is

image=jQuery('.image-holder img').filter(function() {
  return jQuery(this).css('opacity') == '1';
});
alert(img.prop("id"))

Open in new window

Can you post your sendImg function?
Avatar of iceman19330
iceman19330

ASKER

soupBoy --
function sendimg(a){
 alert(a.id);
 //window.location.href='b.html#id='+a.id+'&src='+a.src;
}

Open in new window


Gary -- where would I put that snippet?

thx
I would pop it in here and remove the sendimg(this) - don't see the point of passing the object to another function
function onclick(event) {
//sendimg(this);
} 

Open in new window

I'm probably being obtuse Gary but I dont see that code.

I have
function sendimg(a){
 alert(a.id);
 //window.location.href='b.html#id='+a.id+'&src='+a.src;
}

Open in new window

and images with onClick="sendimg()"

Sorry if I am being difficult.
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Saaaaweet! that works