Reputation: 1
In my MVC project, on a button click event (in jQuery) I am populating a dynamically created Html ul Li
list. It is working fine but when I am using jQuery click event on dynamically created ul Li
, it is not working.
The code is as follows:
$(document).ready(function() {
$('ul.cls-ul li').click(function(e) {
alert(this);
});
})
Is there any better solution?
Upvotes: 0
Views: 173
Reputation: 18973
You need change click function format to
$(document).on('click','ul.cls-ul li',function(){
alert(this);
});
Upvotes: 0