[jQuery] Look for <UL>
[jQuery] Look for <UL>
Hello Everyone,
I tried doing a search and found some possible solutions but was not
able to get it working for my markup so I am wondering if the
following can be done and how.
Markup
<ul class="pages">
<li class="page">
<a class="current" title="Edit index" href="#"> index</a>
</li>
<li class="page">
<a title="Edit menu" href="#"> menu</a>
<ul id="menu" class="categories">...</ul>
</li>
<li class="page">
<a title="Edit menu" href="#"> catering</a>
<ul id="catering" class="categories">...</ul>
</li>
</ul>
So I want to say, when you click on any <li class="page"></li>, look
to see if that <li> has a child <ul>... thats it for now. I later want
to use the effects to "show" and "hide" the contents of that <li>.
jQuery
$(document).ready(function (){
$("li.page").click(function (event) {
if ($(this).find("ul")) {
alert("yes");
} else {
alert("no");
}
});
});
Thoughts? Is there a better way or better functions to use?
I tried find and children.