Question
if my html looks like this:
<div id="result_root" class="expand_image">
<image id="expAllArtistImg" class="expImg" src="images/16-arrow-right.png" onclick="expand(this, 'artists', 'artists');"></image>
<h1>All Artist</h1>
</div>
and my javascript looks like this:
//change arrow image
$(callingImg).attr("src","images/16-arrow-down.png");
//change arrow onClick function
$(callingImg).unbind('click');
why doesn't the onclick event get removed from the image after I click it?
Solution
unbind only removes events added by jQuery. That is, this will work:
$(callingImg).bind("click", function(){expand(this, 'artists', 'artists')});
//And then sometime later:
//change arrow image
$(callingImg).attr("src","images/16-arrow-down.png");
//change arrow onClick function
$(callingImg).unbind('click');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow