Why does my jQuery click handler appear to run multiple times for some of its targets?

前端 未结 7 520
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-11 10:34

I apply:

$(\".newContentLink\").click(function() {
    $(\"#test\").append(\"1\");
});

On this:



        
7条回答
  •  执念已碎
    2021-01-11 11:22

    or you can unbind the click event each time you add a new element

    $('.newContentLink').unbind('click');
    
    $(".newContentLink").click(function() {
        $("#test").append("1");
    });
    

提交回复
热议问题