Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to hide all the divs under a div class and show a div of the same class in JQuery?
    primarykey
    data
    text
    <p>I have a div class named "subproperties". In that div, I have many div elements like border,background,logo,button. These div elements are hidden initially(using style="display:none;") </p> <p>I also have a drop down box with these div element names as options. When I click an option say 'logo', that div is showed. Next when I click the option 'border', the 'logo' div should be hidden and the 'border' div should be shown. Similarly for all cases.</p> <p>That is, I want all the divs of the class subproperties to be hidden and show only one. how to do that in jquery?</p> <p>Here is my code.</p> <pre><code> $("#properties option").click(function(){ selectedOption=$(this).attr("value"); switch(selectedOption){ case '1': $("#borders").show(); break; case '2': $("#backgrounds").show(); break; case '3': $("#typography").show(); break; } }); &lt;div class="float_left spaceleft" id="properties"&gt; &lt;p class="title1"&gt;Properties&lt;/p&gt; &lt;div class="seperator"&gt;&lt;/div&gt; &lt;select id="propertiesMenu" class="select" size="7"&gt; &lt;option value="1"&gt;Borders&lt;/option&gt; &lt;option value="2"&gt;Backgrounds&lt;/option&gt; &lt;option value="3"&gt;Typography&lt;/option&gt; &lt;/select&gt; &lt;/div&gt;&lt;!--End of properties --&gt; &lt;div class="subproperties"&gt; &lt;div class="float_left spaceleft" id="backgrounds" style="display:none;"&gt; &lt;p class="title1"&gt;Backgrounds&lt;/p&gt; &lt;select id="backgroundsMenu" class="select" size="7"&gt; &lt;option value="bgHtml"&gt;Wallpaper&lt;/option&gt; &lt;option value="bgForm"&gt;Form&lt;/option&gt; &lt;option value="bgInstruct"&gt;Instructions&lt;/option&gt; &lt;/select&gt; &lt;/div&gt;&lt;!--End of backgrounds --&gt; &lt;div class="float_left spaceleft" id="typography" style="display:none;"&gt; &lt;p class="title1"&gt;Typography&lt;/p&gt; &lt;div class="seperator"&gt;&lt;/div&gt; &lt;select id="typographyMenu" class="select" size="7"&gt; &lt;option value="ftFormTitle"&gt;Title&lt;/option&gt; &lt;option value="ftFormDescription"&gt;Description&lt;/option&gt; &lt;option value="ftFieldTitle"&gt;Field Title&lt;/option&gt; &lt;option value="ftFieldText"&gt;Field Text&lt;/option&gt; &lt;/select&gt; &lt;/div&gt;&lt;!--End of typography --&gt; &lt;div float_left spaceleft" id="borders" style="display:none;"&gt; &lt;p class="title1"&gt;Borders&lt;/p&gt; &lt;select id="bordersMenu" class="select" size="7"&gt; &lt;option value="brForm"&gt;Form&lt;/option&gt; &lt;option value="brDivider"&gt;Sections&lt;/option&gt; &lt;/select&gt; &lt;/div&gt;&lt;!--End of borders --&gt; &lt;/div&gt;&lt;!-- End of sub properties --&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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