so I am creating a website that has dynamically added content and I want to bind on click events to the list items. The problem is I have a list item within a list item and I can not seem to get the second one to work.
HTML
<ul id="users" class="grid">
<li>
<figure>
<img src="image source" alt="Title" />
<figcaption>
<div>
<h3>Title</h3>
<ol>
<li> <span>Additional Button</span> </li>
<li> <span>Additional Button</span> </li>
<li> <span>Additional Button</span> </li>
</ol>
</div>
</figcaption>
</figure>
</li>
</ul>
Here is the JS
$('ul#users').on("click", "li", function(e) {
console.log($(this));
});
$('.grid ol').on("click", "li", function(e) {
console.log($(this));
});
The first bind works without an issue but the second one is never called. Does anyone have an idea on how to get this to work. Please keep in mind that the LI elements are all dynamically created.
lielements are dynamic, you have two sets ofli(outer or inner).