Reputation: 917
I the following un-ordered list.
<ul>
<li>
<a class="hlink hlink-1" href="#"> Prank Boss Apps </a>
<ul>
<li> <a href="#"> link 1 </a></li>
<li> <a href="#"> link 2 </a></li>
<li> <a href="#"> link 3 </a></li>
</ul>
</li>
<li>
<a class="hlink hlink-2" href="#"> Uninstall an app. </a>
</li>
<li>
<a class="hlink hlink-3" href="#"> Contact Us </a>
</li>
</ul>
In the un-ordered list, not every list-item will have another un-ordered list.
<li> <a href="#"> blah </a>
<ul>
<li> <a href="#"> link 1 </a></li>
<li> <a href="#"> link 2 </a></li>
<li> <a href="#"> link 3 </a></li>
</ul>
</li>
So some will just have a link inside of the list item and others will have a un-ordered list inside.
How can I check if the list item doesn't have another un-ordered list inside of it?
Upvotes: 0
Views: 873
Reputation: 7461
Once you've got a reference to the li element you can use this.
function isLeafNode(liElement) {
return !liElement.getElementsByTagName("ul").length;
}
Upvotes: 1
Reputation: 57693
This should get you started: http://www.w3schools.com/dom/dom_element.asp (if you don't want to use jQuery)
Upvotes: -1
Reputation: 5237
function hasChildULs(thisList)
{
if ($(thisList).children('ul').length > 0)
{
return true;
}
else
{
return false;
}
}
Upvotes: 3