我想从孩子们那里获取顶级菜单的所有信息
<li class="l-nav-item dropdown"><button class="open-icon visible-xs fa fa-angle-down"></button><a href=" ">Home</a>
<ul class="dropdown-menu l-nav-sublist">
<li class="l-nav-subitem"><a href="">Home Style I</a></li>
<li class="l-nav-subitem dropdown"><button class="open-icon visible-xs fa fa-angle-down"></button><a href="">Home Style II</a>
<ul class="dropdown-menu l-nav-sublist">
<li class="l-nav-subitem"><a href="">Home Style I</a></li>
<li class="l-nav-subitem"><a href="">Home Style II</a></li>
<li class="l-nav-subitem"><a href="">Home Style Portfolio</a></li>
<li class="l-nav-subitem dropdown"><button class="open-icon visible-xs fa fa-angle-down"></button><a href="">Home Style II</a>
<ul class="dropdown-menu l-nav-sublist">
<li class="l-nav-subitem"><a href="">Home Style I</a></li>
<li class="l-nav-subitem"><a href="">Home Style II</a></li>
<li class="l-nav-subitem"><a href="">Home Style Portfolio</a></li>
<li class="l-nav-subitem"><a href="">Subitem</a></li>
</ul>
</li>
</ul>
</li>
<li class="l-nav-subitem"><a href="">One Page Home</a></li>
<li class="l-nav-subitem"><a href="">Without Header</a></li>
</ul>
</li>
我想根据li子元素的顶级父元素输出它们。我使用一个名为
$item->megamenu
此字段仅出现在顶部li元素上。例如
if($item->megamenu == 1 ) {
do something
}
但这对孩子没用所以我需要
if($theparentitem->megamenu == 1) {
}
其中,$theparentitem是$项的顶级父项