As an aside, you can use a different syntax for .find() which last I knew was a bit faster and less characters:
$(this).find('.someclass') is equivilent to: $('.someclass', $(this)) On Mar 17, 8:58 pm, "so.phis.ti.kat" <see.marlon....@gmail.com> wrote: > Thanks for the tip. I started to use FF's console to see more details > of the object(s) > Here's my code: > > $(document).ready(function (){ > $("li.page").click(function (event) { > var secondList = "ul.categories"; > if ($(this).find(secondList).length > 0) { > > $(this).children(secondList).slideToggle("slow"); > } > }); > > }); > > On Mar 17, 12:18 pm, mkmanning <michaell...@gmail.com> wrote: > > > if ($(this).find("ul")) { ... > > > will always return a jQuery object and so evaluate to true; you need > > to check the length: > > > if ($(this).find("ul").length>0) { ... > > > On Mar 17, 8:57 am, "so.phis.ti.kat" <see.marlon....@gmail.com> wrote: > > > > 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.