javascript - jQuery : dynamically created div ID can't be selected? -
this question has answer here:
$('#content').droppable({ drop:function(event , ui){ $('<div>').appendto('#content'); $('#content div').load('div.html'); } }); below code doesn't select divcontainer id
$('#divcontainer').click(function(){ $('#divcontainer').hide(); }); this html page div.html
<div id="divcontainer"> samplediv </div> the div gets added page can't select div using it's id !
the $('#divcontainer').click code needs go inside done section once data loaded in
$('#result').load('div.html', function() { $('#divcontainer').click(function(){ $('#divcontainer').hide(); }); }); or use on() explosion pills said
Comments
Post a Comment