html - CSS / jQuery Multilevel List -
I am trying to create a multilevel list which should initially look like the following:
Level_1
Then when I click on any of the "Level_1" text (say the top one), "Level_2" should be displayed, like:
Then when I click on "Level 2" (one below says), "Level 3" below "level 2" Should be visible, which has been clicked, such as:
level_1 level_2 level_ 2 level_3 level_3 level_3 level_1
Then when I click again on the second "level_2", it should be
Level_1 Level_2 Level_2 Level_1
< / Pre>
I have something so far (I suspect that it does not work as jQuery, the function activates twice when clicking on "Level_2", a Bar for "Level_1" ("Level 2" is embedded within "Level_2") and once for "Level 2"):
jQuery:
< Pre>& lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> & Lt; Script & gt; $ (Document) .ready (function () {$ ("level_3"). Click (function () {console.log ($ (this)) jQuery (this). Find ("Level_4") Toggle () (". Level 2"). $ (". Level2") (function () {jQuery (this) .Find (".3 level") Toggle ();}); $ ("Level_1" ) Click (function) {JQuery (this) .Find ("Level 2") Toggle ();});}); & Lt; / Script & gt;
CSS:
& lt; Style & gt; . Level_1 {Text-Indent: 25px; Z-index: 1; Background color: red; }. Level_2 {Text Indent: 50px; Z-index: 2; Background color: green; }. Level_3 {Text indent: 75px; Z-index: 3; Background color: blue; } & Lt; / Style & gt;
HTML:
& lt; Div class = "level_1" & gt; Level_1 & lt; Div class = "level_2" & gt; Level_2 & lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "level 2" & gt; Level_2 & lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "level_1" & gt; Level_1 & lt; Div class = "level_2" & gt; Level_2 & lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "level 2" & gt; Level_2 & lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; Div class = "Level_3" & gt; Level_3 & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
How should this look after each "Level_1" and "Level_2" click once ("Level_3" will later become a link on the second page) :
level = level level level level level level level level level level level level level level level level level level level level level level << / div> You should control the goal of the click event
$ (document) .ready (function () {$ (" Level_3 "). Click (function ) {If ($ (E.target) .is (' ($ (This level) ".find (". Level_4 "). Toggle ();}}) $ (" Level_2 "). Click (function (E) {if ($ (e.target) .is ('. Level_2')) {$ (this) .find ("Level_3"). Toggle ();}}); $ (". Level_1") Click (function (e) {if ($ (e .target) .is ('. Level_1')) {$ (this) .find ("Level_2") toggle ();}});});
Comments
Post a Comment