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...
});
精彩评论