I have generated few elements in my page using following method. For example,
$("#button"+caption).click(function(){
var firstDisplay = '<div id="firstDisp'+caption+'"><ul>';
for(var i=0;i<parents.length;i++){
firstDisplay=firstDisplay+'<li class="fClick">'+parents[i]+'</li>';
}
firstDisplay=firstDisplay+'</ul></div>';
$(firstDisplay).dialog();
});
and when i create an onclick event for 'fClass' like so :
$(".fClick").click(function(){
alert("hey!");
});
It does not works ! However, if i put the onclick function inside the other function, right after .dialog(), it works ! I have a lot of elements created this way, so I cannot put all onclick events in a single method. Is there any way around this? I am having the same problem with .append method as well.