c# - How can I setup Javascript dynamically to expand divs when clicking another div? -


i creating main menu in asp.net using dynamically created divs.

the divs associated 3 different levels.

i have done need struggling expanding , collapsing menus.

i need show level 1 items when page loaded (probably easier using css?)

then need able expand level2 items particular level1 item when item clicked.

i need collapse them after time period.

the code below shows how divs created , statements specific levels:

  private void creatediv(string divid, string url, int level)     {         //attributes items         htmlgenericcontrol div = new htmlgenericcontrol("div");         div.attributes.add("id", divid);          div.controls.add(             new label()             {                 id = "lbl" + divid,                 text = divid             });           if (level == 1)         {              div.attributes.add("class", "level1");             //code expand level 2 items          }          if (level == 2)         {             div.attributes.add("class", "level2");             //code expand level 3 items         }         if (level == 3) //specific attributes level 3 items         {             div.attributes.add("class", "level3");             div.attributes.add("onclick", "window.open('" + url + "', 'mywindow');");         }         divmenuleft.controls.add(div);      } 

css:

<style type="text/css"> #content > div { display: none; }  #content > div:target { display: block; }</style> 

html: (list item link)

<ol> <li>     <a href="#div1">menu item main</a></li> </ol> 

html:

<div id="div1">     <a>         menu item child</a> </div> 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -