In my responsive side menu, there is a submenu structured like this:
.navbar ul li ul
I would like the child menus to be hidden and only shown when the parent menu is clicked.
Although I attempted to achieve this with the following code, it was unsuccessful.
$(".navbar ul li").each(function(index, element) {
if ($(this).children('ul').attr('class')){
}
else {
$(this).find('span').remove();
}
});
$(".navbar ul li span").click(function(){
$(this).toggleClass('ss');
$(this).parent('li').toggleClass('active-mobile');
$(this).parent('li').children('ul').slideToggle();
});