Note that there are some explanatory texts on larger screens.

plurals
  1. POclosing the submenu on clicking the next menu
    primarykey
    data
    text
    <p>I have the following javascript :-</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; function HideandUNhideObj(ThisObj){ nav=document.getElementById(ThisObj).style if(nav.display=="none"){ nav.display='block'; }else{ nav.display='none'; } } &lt;/script&gt; </code></pre> <p>And I have the following HTML code for the menus and sub menus</p> <pre><code> &lt;ul&gt; &lt;li&gt;&lt;a href="#" onclick="HideandUNhideObj('div1');"&gt;Menu 1&lt;/a&gt; &lt;div style="display: none;" id="div1"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#" onclick="HideandUNhideObj('div2');"&gt;Menu 2&lt;/a&gt; &lt;div style="display: none;" id="div2"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>But on one click makes a submenu appear and clicking it again hides it.</p> <p>I need to hide the sub menus, when we click on the next menu. Only one Menu should open the sub menus in it. </p> <p>Now, I can open two menus, having its sub menus in it, and on clicking the menu only, will hide those.</p> <p>Please help. </p> <p>The sample menu I created :-</p> <p><img src="https://i.stack.imgur.com/PW9xb.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload