tags:

views:

96

answers:

1

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?

+3  A: 

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');
Marius
What would be the best way to change an onclick event set in the html then?
danwoods
$(callingImg)[0].removeAttribute("onclick");
Marius
Thanks man_____
danwoods