Thanks for all your input. Here's a look at what I have so far: http://www.marlonvalenzuela.net/apps/cms/thechickenplace.html
Since we are talking about best-practice, here is how i am switching between the + and - characters var pm = $(this).children(".plusminus"); switch (pm.html()) { case "-": pm.html("+") break; case "+": pm.html("-") break; } which is inside... $("a.toUpperCase").click(function (event) { var p = $(this).parent(); var secondList = "ul.categories"; if ($(p).find(secondList).length > 0) { $(p).children(secondList).slideToggle("slow"); var pm = $(this).children(".plusminus"); switch (pm.html()) { case "-": pm.html("+") break; case "+": pm.html("-") break; } } }); Would you do it a different way? I look through the docs this morning but couldn't find a "shortcut" to using the switch statement On Mar 18, 9:10 pm, ricardobeat <ricardob...@gmail.com> wrote: > It's not faster, it actually adds a bit of overhead. From jQuery > source code: > > // HANDLE: $(expr, $(...)) > } else if ( !context || context.jquery ) { > return (context || rootjQuery).find( selector ); > > that means everytime you type $('.someclass', this) it's effectively > being "translated" to $(this).find('.someclass'). > > cheers, > - ricardo > > On Mar 17, 10:02 pm, Eric Garside <gars...@gmail.com> wrote: > > > 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.