jQuery $(this).remove() not working after append

后端 未结 2 1013
太阳男子
太阳男子 2021-01-02 03:46

I have a div with class=\"tags\" with one predefined hyperlink.

myLink
相关标签:
2条回答
  • 2021-01-02 04:16

    Your click event only attached to current dom element not to future element.If you want to add this event to all element include future then you have to use live event in jquery. http://jsfiddle.net/6cGvt/

    0 讨论(0)
  • 2021-01-02 04:31

    You have to use the live-function:

    $(".tags a").live("click", function() {
        // ...
    });
    

    Because you are adding the links after the initial load, the standard click event won't be binded to the dynamic added links.

    0 讨论(0)
提交回复
热议问题