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

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

I apply:

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

On this:



        
7条回答
  •  轮回少年
    2021-01-11 11:09

    Not a jQuery bug - Working Demo

    There must be a problem with something else in your code. Where is the element with id="test" in your markup?

    EDIT:

    Just read chaos' answer, which sounds like a plausible explanation.

    By the way, element ids must be unique within HTML markup - this is part of the HTML specification and may be another possible explanation

提交回复
热议问题