开发者

jQuery .live() only works one time

I have a simple jQuery AJAX code which generates XHTML code:

$("a.close").live("click", function( e ){
  开发者_StackOverflow  e.preventDefault();      
    $( '#info' ).fadeOut( 'slow' );
});

This code works great once. My div closes and everything is fine, but if I click on the link that opens up my #info div a second time then I can't close the div. I get no errors in Firebug and I can't solve the problem.


Could you try returning false instead of calling e.preventDefault?


Try the following:

$("#info").fadeOut('slow').remove();

It's possible you're adding multiple '#info' boxes, but not actually removing the old ones - just hiding them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜