I have a div that has a class cls1 .
When I click cls1 div a new div is created having the same class as this one.
But when I click the newly created cls1 div it doesn’t create another div…
The class is correct because the CSS rules are applied.
I am using jQuery. Is there any reason for the newly created div not to trigger the click event when clicked?
EDIT1:
I tried creating the new div with append but also by making a new jQuery object.
For this to work, you need to use
.live()or.delegate()to bind the event. These will bind the event to newly created elements.If you just used
.click(), or.bind(), it bound the elements that existed at that time, and that’s it.