无法使用Jquery.contains()检查<li>中的嵌套<ul>

Main issue | $.contains(arg1, arg2)

I'm not able to get the $.contains() to work.
I want to check if the <li> has a nested <ul class="sub-menu"> but no matter what format i put the aruments in I always get an output of false. (want to eventually wrap that in a if statement to edit some CSS)

下面的更多信息

JS

$( 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);
  }
}

的HTML

<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>

在这里,我希望能够使用Js + Jquery有条件地编辑CSS(Codepen具有基本的CSS)

Codepen

一些背景

因此,我要在WordPress上创建主题,并希望使用WordPress的内置菜单管理器,而不想让WordPress为每个列表项和子菜单列表创建类等等麻烦。