How select second ul element with "dropdown-menu" class inside ul element with same class?
<ul class=" dropdown-menu">
<li>
<ul class=" dropdown-menu">
</ul>
</li>
</ul>
If you want to select just the 2nd element, here is the workaround:
.dropdown-menu .dropdown-menu:first-child {}
More specific version:
ul.dropdown-menu li ul.dropdown-menu:first-child {}
$('.dropdown').find('.dropdown:first').addClass('child-dropdown-menu');
Cheers!
Here's a pure js answer I'm assuming you already have the ul reference in a variable.
var uls = ul.getElementsByTagName("ul");
var targetUl = undefined;
for(var i = 0; i < uls.length; i++){
for( var j = 0; j < uls[i].classList.length; j++){
if(uls[i].classList[j] == "dropdown-menu"){
targetUl = uls[i];
break;
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.