JSFiddle - React, Tailwind, and code Playground
by jdcutter
HTML
<ul class="top-menu">
<li id="menu-item-744" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-744 menu-item-has-children"><a href="#">Clickable title item</a>
<ul class="sub-menu" style="display: none;">
<li id="menu-item-288" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-type-post_type menu-item-object-post menu-item-288"><a href="http://xyz.com">Post 2nd lvl</a></li>
<li id="menu-item-290" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-type-post_type menu-item-object-post menu-item-290"><a href="http://xyz.com">Post 2nd lvl</a></li>
<li id="menu-item-292" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-type-post_type menu-item-object-post menu-item-292"><a href="http://xyz.com">Post 2nd lvl</a></li>
</ul>
</li>
</ul>
JavaScript
$('ul.top-menu').children('.menu-item-has-children').click(function(){
$(this).children('.sub-menu').slideToggle('slow');
}).children('ul').find('.menu-item').click(function (event) { //select all the `.child` elements and stop the propagation of click events on the elements
event.stopPropagation();
return false;
});