Hello, I at the touch of a button create a new div, inside which there is a button. Can you please tell me how to handle it?
$("#btn2").click(function () { var dynDiv = $('<div>') .attr('id', 'div_' + dname_id++) .css({ 'width': '50px', 'height': '20px' }) .addClass('resize') .html("<button id='dbtn' >click</button>"); $('#dbtn').click(function () {alert("ghj")}) $('#container').append(dynDiv); //-------------------------------------------------------// dynDiv.click(function () { $('.selected').removeClass('selected'); $(this).addClass('selected'); }); }); I tried, but without success. Thanks in advance!