开发者

Javascript click event not running on all class elements

I have a button of class 'add' which, when clicked simply clones itself and its other div siblings. The cloning works fine, however the click functionality only works on the first instance of the button (the one that loads with the page) and not on any subsequent instances.

Any help would be great.

$('.add').click(function(){
        cloneDiv();
 开发者_高级运维   });


Use the live method for dynamically added elements:

$('.add').live('click', function(){
    // your code...
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜