javascript - .on not working on dynamic html -


i creating drag , drop thing. when drop happens create new runtime html , want bind event, have used following .on

 .on ( "event", "selector", function() { 

but not working. here snippet :

$( "#wrap .dragimages" ).on( "click", "button.edit-new-modal", function() {     var photoid = $(this).attr('data-username');             alert(photoid); }); 

.on works before drag , drop. afterwords nothing happens on clicking "button.edit-new-modal"!! what's wrong? solution?

try :

$(document.body).on( "click", "button.edit-new-modal", function() {   var photoid = $(this).attr('data-username');           alert(photoid); }); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -