how to access dynamically created list in jquery?
- by Ohana
hi,
i have a unordered list of links, which are dynamically created by Ajax, and for each link i want to add click function to it, but it won't work, please help!
here is my code:
html:
list
//to create links
var str = '';
$.each(json.opts, function(i, opt) {
var id = opt + '-list';
str += '' + opt + ''; //link
}
$("#list").html(str);
...
//to add click function to each links, this won't work
$("#list li").each(function (i) {
alert(i + " : " + $(this).text());
});