| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Jan 2006
Posts: 146
|
jquery rollover/rollout conflict
another request for help *sigh* i've got three navigation items, and when i rollover one item, a div with a submenu slides down beneath that nav item. this all works perfectly. what i can't fix: when i rollout on one item, and do a rollover on another, the other submenu should disappear and the other appear but when i hover/navigate in a submenu div the div of course should stay visible. but it disappears because i have that rollout function attached to the nav item initially i don't want to add a close button on each submenu div, or let it dissappear when you click on a link in the submenu. code: Code:
i tried adding Code:
but then of course it still slides up before going back down i hope this is somewhat clear.. and i know it's a stupid thing, but i'm kinda new to jquery, and i'm a bit stuck thanx! |
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,336
|
Just threw this together. It works. Explanation in the JavaScript comments. One thing I will say, storing your elements in arrays is handy and can really speed up your scripts. This is because if you repeat a selector - for instance $("ul#nav > li") - jQuery has to decode that and traverse the DOM to find it each time. Also, be as specific as possible for your purposes when building selectors - the more specific your selector, the faster jQuery can traverse the DOM. After storing the <li>s, you can find any children of a stored element easily by adding that as a context for your DOM search - $("a", navItems) - will find all <a> elements within the context of your stored "navItems" array (which, as you'll recall stores $("ul#nav > li"). So, $("a",navItems) means the same thing as $("ul#nav > li a"), but it's faster because jQuery doesn't have to traverse the entire DOM to find those elements each time. HTML Code:
|
|
![]() |
|