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

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

I apply:

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

On this:



        
7条回答
  •  不思量自难忘°
    2021-01-11 11:12

    To make sure the function only execute once on one click event you may use $(".newContentLink").one();

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

提交回复
热议问题