I have some code that allows the user to create divs with some content in them on a page. These divs are dynamically generated and I need a click event that fires when a user clicks on any one of the dynamically generated divs.
All the dynamically created divs have class="entry"
.
<div class="entry">
//some content
</div>
<div class="entry">
//some other content
</div>
//...
Following the answer given here my code looks like this:
$('body').on('click','div.event',function(){
console.log("clicked");
//do stuff
});
However this event does not seem to fire as console.log("clicked") is never executed. What am I doing wrong and how do I fix this?
EDIT: Sorry guys it was just the typo. I cannot believe I didn't spot that before. So sorry for wasting your time, unfortunately I cannot delete the question now that people have answered it.