Sunday 15 April 2012

jQuery Multiple .slide() In Navigation Without Selectors -


I'm making a responsive topic for anyone I've created a menu, but I used jQuery slides to use jQuery. Using slide (). The problem is that when I toggle the menu open, it also opens all the sub-menus in it.

I can add selectors to fix this problem. However, by adding selectors, this means that the user should add the sub-menu if he may have to change the jQuery so I am trying to keep it so that the user never have to touch jQuery.

Is there a solution to this problem?

HTML :

  & lt; Div id = "linkList1" & gt; & Lt; Div class = "menu-toggle" & gt; Menu & lt; / Div & gt; & Lt; Ul class = "firstlevel" & gt; & Lt; Li & gt; The first link & lt; / Li & gt; & Lt; Li class = "shared-toggle" & gt; The first link & lt; Ul class = "secondlevel" & gt; & Lt; Li & gt; First drop link & lt; / Li & gt; & Lt; Li & gt; Second drop link & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt;   

CSS :

  ul {display: none; }   

jQuery :

  $ ("menu-toggle"). Click (function () {$ ("# linklist 1 ul"). Slide toggle ("sharp");}); $ ("Share Toggle"). Click (function () {$ ("# LinkList1 ul ul"). Slide Toggle ("sharp");});   

Flood :

try Do it

  $ ("menu-toggle"). Click (function (e) {$ (this) .next ('ul') Slide Toggle ("sharp");}); $ ("Share-toggle"). Click (function (e) {$ (this) .find ('ul') SlideToggle ("sharp");});                

Then you will use the this context, which organizes the current selected element that generates the event and related the Ul shows . >

No comments:

Post a Comment