i need add class dropdown-submenu
parent li
if has inner ul
element class dropdown-menu
. example of html code:
<ul class="dropdown-menu" id="menu1"> <li> <a href="#">more options</a> <ul class="dropdown-menu"> <li><a href="#">second level link</a></li> <li><a href="#">second level link</a></li> <li><a href="#">second level link</a></li> <li><a href="#">second level link</a></li> <li><a href="#">second level link</a></li> </ul> </li> </ul>
i didn't try yet because don't know how check if <ul class="dropdown-menu">
exists in each li
element. help?
you use jquery .has()
function:
$('li').has('ul.dropdown-menu').addclass('dropdown-submenu');
or use :has
selector:
$('li:has(ul.dropdown-menu)').addclass('dropdown-submenu');
Comments
Post a Comment