I have html that looks like this:
<ul>
<li class="database">Item One
<ul>
<li>Sub One</li>
<li>Sub Two</li>
<li>Sub Three</li>
</ul>
</li>
<li class="database">Item Two
<ul>
<li>Sub One</li>
<li>Sub Two</li>
<li>Sub Three</li>
</ul>
</li>
<ul>
I then created this JavaScript to hide/show the sub list when clicked.
$(document).on('click', 'li.database', function (e) {
e.stopPropagation();
$(this).children('ul').children('li').toggle();
});
It works, but it hides the list no matter if I click on the submenu or not. How can I hide the items only when the root li
is clicked? I would like to eventually have the sub items have their own events when clicked.