javascript - Call js code on button click -


here have code , when click on button must add div id new div id bottom dont know wrong:

contentstr += '<button class="dodaj">add timeline</button></div>';  $(".dodaj").click(function() {   $('#bottom').append($('<div id="new">'+place.name+'</div>').css('marginleft',100)); });  $(contentstr).dialog({ modal:true }); 

so first call contentstr in modal window jquery ui , in modal window must call button class .dodaj , id bottom add div id new

so wrong here?

use .on()

as button added dynamically not accessible directly ,so have use event delegation.

$(document).on("click", ".dodaj", function () {     $('#bottom').append($('<div id="new">' + place.name + '</div>').css('marginleft', 100)); }); 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -