javascript - Best way to Hide or Show contents of div based on list based menu -


I have to show or hide the contents of the div based on menu selection.

Below is my structure

  & lt; Div id = "menuContainer" & gt; & Lt; P & gt; Menu & lt; / P & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Menu Two & lt; / A & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Sub menu one & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Sub menu two & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Sub menu three & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Sub menu four & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Menu three & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Contact & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Div class = "row" & gt; & Lt; Div id = "home" & gt; & Lt; H1 & gt; This is the home page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "menuTwo" class = "content" & gt; & Lt; H1 & gt; This menu is two page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "submenuon" class = "content" & gt; & Lt; H1 & gt; This sub menu is a page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "SubMenuTwo" class = "content" & gt; & Lt; H1 & gt; This sub menu is two page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "SubMenuThree" class = "content" & gt; & Lt; H1 & gt; This sub menu is three pages & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "SubMenuFour" class = "content" & gt; & Lt; H1 & gt; This sub menu is a four page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "menuThree" class = "content" & gt; & Lt; H1 & gt; This menu is three pages & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "menuFour" class = "content" & gt; & Lt; H1 & gt; This menu is a four page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "contact" class = "content" & gt; & Lt; H1 & gt; This contact page is & lt; / H1> & Lt; / Div & gt; & Lt; / Div & gt;   

I also got an example on which any such work does.

It seems that Dojo is not that I'm not familiar with. Is there any other way to do this with a simple script?

My Bela example:

JSFIDDLE

JQUERY:

  $ (document) .ready (function () {$ ('.row div'). (), $ ('# Home'). Show ( ); // If you want to show the home screen for the first time ('# menuContainer a'). Click (function () {var id = $ (this) .attr ('href'); $ ('.row div) '). Hide (); $ (id). FadeIn ("250");});});   

New HTML:

  & lt; Div id = "menuContainer" & gt; & Lt; P & gt; Menu & lt; / P & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#home" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#MenuTwo" & gt; Menu Two & lt; / A & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#SubMenuOne" & gt; Sub menu one & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#SubMenuTwo" & gt; Sub menu two & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#SubMenuThree" & gt; Sub menu three & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#SubMenuFour" & gt; Sub menu four & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#MenuThree" & gt; Menu three & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# contact" & gt; Contact & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Div class = "row" & gt; & Lt; Div id = "home" & gt; & Lt; H1 & gt; This is the home page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "menuTwo" class = "content" & gt; & Lt; H1 & gt; This menu is two page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "submenuon" class = "content" & gt; & Lt; H1 & gt; This sub menu is a page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "SubMenuTwo" class = "content" & gt; & Lt; H1 & gt; This sub menu is two page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "SubMenuThree" class = "content" & gt; & Lt; H1 & gt; This sub menu is three pages & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "SubMenuFour" class = "content" & gt; & Lt; H1 & gt; This sub menu is a four page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "menuThree" class = "content" & gt; & Lt; H1 & gt; This menu is three pages & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "menuFour" class = "content" & gt; & Lt; H1 & gt; This menu is a four page & lt; / H1> & Lt; / Div & gt; & Lt; Div id = "contact" class = "content" & gt; & Lt; H1 & gt; This contact page is & lt; / H1> & Lt; / Div & gt; & Lt; / Div & gt;    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -