Jump to content

JQuery click event is not working on dynamically created ul Li list in mvc

Recommended Posts

In my website https://www.giftstoindia24x7.com , 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?

Edited by Niladri

Share this post

Link to post
Share on other sites

You have to target parent elements that already exists then created child element using .on() jQuery function.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...