Sunday, 15 September 2013

Click action from cloned element

Click action from cloned element

Click action won't work on any cloned element. See it on:
http://jsfiddle.net/Q9m4t/
HTML
<ul>
<li>hello <a class="del" href="#">del</a></li>
<li>new <a class="add" href="#">add</a></li>
</ul>
JS
$(".add").click( function() {
$(this.parentNode).prev("li")
.clone()
.insertBefore(this.parentNode);
return false;
});
$(".del").click( function() {
$(this).closest("li").remove();
return false;
});
Can anyone help please?

No comments:

Post a Comment