treehouse : what would you like to learn today?
Web Design Web Development iOS Development

simple jquery dropdown

  • I'm trying to get this to work on this site and failing - it looks like it should be simple enough to implement but I can't see where I'm going wrong. any suggestions? thanks.
  • Well, for starters, you're not calling the main jQuery library file anywhere...that's an essential part.
  • at the top, about the 8th line down
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script&gt;
    . I use this for anything slider, can't I also use it for the dropdown?
  • Wasn't there first time I checked...?? Anyhoo, yes, you can use this for any jQuery plugin, it's the main part of anything jQuery so that can't be the source of the problem.
  • Simple, most importantly, you dont have the subMenu UL inside of the parent dropdown LI....go here for working example:

    http://jsfiddle.net/TRSwU/

    any questions let me know!
  • @kgscott284 - thanks for the reply. I can see on jsFiddle how nicely your solution works but I can't get it to work. I tried putting the jquery into an external file and putting it internally but neither is working. I hope its not due to a typo but if you wouldn't mind looking here maybe you can see my error. Also can you explain if the zoom property is necessary and what does this line do
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
    ? do I need it? Many thanks!
  • That code is to insert an &raquo; on the li elements that has children ul. That's used to make automatic submenu indicators.