$.contains(arg1, arg2)
but no matter what format I put the arguments in I always get an output of $.contains()
. (want to eventually wrap that in a if statement to edit some CSS) <li>
More info below<ul class="sub-menu">
JSfalse
HTML
$( document ).ready(navSecondary());
function navSecondary(){
var firstListSize = $("nav.header-secondary>ul>li").length;
for (var i = 0; i < firstLiSize; i++) {
var nav = $("nav.header-secondary>ul>li:nth-child("+i+1+")");
var sub = document.documentElement.getElementsByTagName("ul");
var check = $.contains(sub,nav);
console.log(check);
}
}
<nav class="header-secondary">
<ul>
<li><a href="#">item 1</a>
<ul class="sub-menu">
<li><a href="#">Sub Option 1</a></li>
<li><a href="#">Sub Option 2</a></li>
<li><a href="#">Sub Option 3</a></li>
</ul>
</li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 3</a></li>
</ul>
</nav>
So I'm creating a theme on WordPress and want to use WordPress's inbuild menu manager, I don't want to go through the hassle of asking WordPress to create classes for each list item and sub menu list so on and so forth. EDIT- I realize there is an easier way to do the CSS (through the classes WordPress would add to the menu items) but I wanted to try and do it through Jquery
Main issue