Finding a child element of a wrapped set
Hello,
I'm trying to add a click listener to a list element that has a hidden unordered list.
-
<script type="text/javascript">
$(function(){
$('li:has(ul)').click(function(event)
{
if (this == event.target)
{
if ($(this).next().is(':hidden'))
{
$(this).next().show();
}
else {
$(this).next().hide();
}
}
return false;
})
});
</script>
/* With a list something like this */
<ul>
<li>One</li>
<li>Two
<ul>
<li>Two.one</li>
</ul>
</li>
</ul>
Basically, I'm looking for a way to find a list element that has a ul child, and then hide or show that ul. What I have here doesn't seem to be working. Thanks in advance.