Selvamani Selvamani - 3 months ago 11
CSS Question

Add button dynamically using jquery

I am trying to add button dynamically, Here first button is only working but not other buttons, previously I was using

function, but jquery 1.9.1 removed that function. So what I do for to get work newly added buttons.

Here my html code

<div class="take">
<p>this is the para</p>
<button class="test">copy</button>

Here my juery code

$('.test').on('click', function() {
var a = $(this).parent();

Here the jsfiddle: fiddle


Passing true in clone will solve your problem - jsfiddle

$('.test').on('click', function() {
    var o = $(this).parent();

Note: new is a keyword in JavaScript so don't use it as a variable.