This example for you to share the jquery three level drop-down menu of the specific implementation code for your reference, the specific content as follows
In writing this, first of all, to smooth out the idea. Click on a menu, the other to close, point level menu, the level two or three menu to close, and so on.
The approximate code is as follows:
<body> <aside> <ul class= "One" > <li> <a href= "#" class= "a" > directory a</a> <ul C Lass= "Two" style= "Display:none" > <li><a href= "#" class= "a" > Level two directory a</a> <ul "class=" style= "Display:none" > <li><a href= "#" > Level three directory a</a></li> </ul> </li>
; <li><a href= "#" class= "a" > Level two directory b</a></li> <li><a href= "#" class= "a" > Level two directory c</a& gt;</li> </ul> </li> <li> <a href= "#" class= "a" > directory b</a> <ul class= "tw O "style=" Display:none "> <li><a href=" # "class=" a "> Level two directory a</a> <ul class=" three "style=" Display:none "> <li><a href=" # "> Level three directory a</a></li> </ul> </li> & Lt;li><a href= "#" class= "a" > Level two directory b</a></li> <li><a href= "#" class= "a" > Level two directory c</a& Gt;</li>;/ul> </li> <li> <a href= "#" class= "a" > directory c</a> </li> </ul> </aside>
jquery section <script src= "Js/jquery-1.8.3.min.js" ></script> <script> $ (document). Ready (function () { $ ('. a '). Click (function () {if ($ (this). Siblings (' ul '). CSS (' display ') = = ' None ') {$ (this). Siblings (' ul '). Slidedo
Wn. Children (' Li '); if ($ (this). Parents (' Li '). Siblings (' Li '). Children (' ul '). CSS (' display ') = = "Block") {$ (this). Parents (' Li '). Siblings
(' Li '). Children (' ul '). Slideup (100);
} else {//control itself menu hidden $ (this). Siblings (' ul '). Slideup (100);
Control the menu to hide $ (this). Siblings (' UL '). Children (' Li '). Children (' ul '). Slideup (100);
}
});
});
</script> </body>
If you want to add a style, be sure to note that otherwise the menu may appear to be wrong.
Full code address: Https://github.com/SabrinaTian/ThreeMenuNav.git
git also has a case with an icon, no click is the + number, the menu opened, changed to-number.
The above is the entire content of this article, I hope to help you learn.