Reputation: 3050
I am trying to find and append some text in a dynamically created parent div but its not working. Here is what I have tried.
var mainDiv = "" +
"<div>" +
"<div></div>" +
"<div>" +
"<div class='image-here'></div>" +
"</div>" +
"</div>"; // proper script is in Fiddle
var imageDiv = $(mainDiv).children(".image-here");
$(imageDiv).html("text allocated");
$(mainDiv).dialog();
Here is the Fiddle: http://jsfiddle.net/xBB5x/10166/
Upvotes: 4
Views: 69
Reputation: 8366
Change this:
var imageDiv = $(mainDiv).children(".image-here");
$(imageDiv).html("text allocated");
$(mainDiv).dialog()
to this:
$(mainDiv).dialog().find(".image-here").html("text allocated");
Upvotes: 6