Why am I unable to retrieve the text
of the newly added child divs? I am using JQuery to dynamically add these elements. Here is my sample fiddle: JSFIDDLE
Could someone please guide me on what mistake I made?
Javascript Code:
var counter = 0;
$("button").click(function() {
$("<div class='child-list-workorder'>\
<div class='list-workorder'>\
<div class='list-workorder-header'>\
<h3 id='" + counter + "' class='list-workorder-id'>click me " + (++counter) + "</h3>\
</div>\
<p>" + counter + "</p>\
</div>\
</div>").appendTo("div.parent-list-workorder");
});
$("div.list-workorder-header").on("click", "h3.list-workorder-id", function(){
alert(this.id);
});