1

如果我的 html 看起来像这样:

<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>

我的javascript看起来像这样:

//change arrow image
$(callingImg).attr("src","images/16-arrow-down.png");

//change arrow onClick function
$(callingImg).unbind('click');

为什么点击后onclick事件没有从图像中删除?

4

1 回答 1

3

unbind 只删除 jQuery 添加的事件。也就是说,这将起作用:

$(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');
于 2009-12-13T06:59:41.067 回答