simple jquery image change onclick failing
Posted
by ian
on Stack Overflow
See other posts from Stack Overflow
or by ian
Published on 2010-06-16T03:37:40Z
Indexed on
2010/06/16
3:42 UTC
Read the original article
Hit count: 188
jQuery
I have a simple jQuery image switch that is failing.
$('.heart_img').click(function()
{
var heart_type = $(this).attr('src');
//alert( heart_type );
if ( heart_type == 'images/unheart.png')
{
//alert('uheart');
$(this).attr('src','images/heart.png');
}
else if ( heart_type == 'images/heart.png');
{
$(this).attr('src','images/unheart.png');
}
});
The alerts fire correctly when not commented out so and the images are in the correct place so I am not sure what the problem is.
© Stack Overflow or respective owner