JSFiddle - React, Tailwind, and code Playground
HTML
<nav class="responsive-menu">
<ul>
<li>One</li>
<li>Two
<ul>
<li>Two A</li>
<li>Two B</li>
</ul>
</li>
</ul>
<ul>
<li>Three</li>
<li>Four
<ul>
<li>Four A</li>
<li>Four B</li>
</ul>
</li>
</ul>
</nav>
CSS
*{
box-sizing: border-box;
}
ul {
list-style: none;
margin: 0;
}
a {
text-decoration: none;
}
.responsive-menu {
min-height:60px;
width: 100%;
clear: both;
background: #415A68;
padding: 10px 0;
}
.responsive-menu span {
background: #fff;
height: 40px;
width: 40px;
float: right;
margin: 0 20px 10px 0;
border-radius: 20px;
cursor: pointer;
text-align: center;
font-size: 20px;
font-weight: bold;
padding: 6px 0 0;
transition: background 0.5s ease;
}
.responsive-menu span.active {
background: #6D6F71;
color: #fff;
}
.region-responsive-nav {
padding: 0 0 20px;
display: none;
width: 100%;
clear: both;
}
.region-responsive-nav.open {
display: block;
}
.region-responsive-nav ul li a {
color: #fff;
padding: 10px 20px;
display: block;
font-weight: bold;
background: #415A68;
border-bottom: 1px solid #ADAFB2;
}
.region-responsive-nav ul li a.active {
color: red;
}
.region-responsive-nav ul ul li a {
padding-left: 40px;
font-weight: normal;
background: #354954;
position: relative;
}
.region-responsive-nav ul ul li a:before {
position: absolute;
content: '+';
left: 25px;
font-size: 12px;
top: 12px;
}
JavaScript
$(document).ready(function () {
$('li > ul').hide();
$("li:not(:has(ul))").click(function() {
alert("do something");
});
$("li:has(ul)").hover(function() {
$(this).children("ul").slideToggle();
}, function() {
$(this).children("ul").slideToggle();
});
});