Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Answer here: <a href="http://jsfiddle.net/Hxadj/" rel="nofollow">http://jsfiddle.net/Hxadj/</a></p> <p>There were a few extra things in the code that didn't need to be there. Also you were testing for the value of All. I'm not sure why, what you needed was the value of the select which was done with (this.value == X)</p> <pre><code>$(function() { $('#title').change(function() { if(this.value == "All"){ $("#All").show(); $("#otherTitle").show(); $("#otherTitle2").show(); } else if (this.value == "one") { $("#All").hide(); $("#otherTitle").show(); $("#otherTitle2").hide(); } else if (this.value=="two"){ $("#All").hide(); $("#otherTitle2").show(); $("#otherTitle").hide(); } }); }); </code></pre> <p><strong>UPDATE</strong></p> <p>Link here: <a href="http://jsfiddle.net/Hxadj/1/" rel="nofollow">http://jsfiddle.net/Hxadj/1/</a></p> <p>HTML:</p> <pre><code>&lt;select name="lab_1" id="title" &gt; &lt;option value="All"&gt;All&lt;/option&gt; &lt;option value="otherTitle"&gt;One&lt;/option&gt; &lt;option value="otherTitle2"&gt;Two&lt;/option&gt; &lt;/select&gt; &lt;div id="All" class="togglers"&gt;hiihdhfhdf&lt;/div&gt; &lt;div id="otherTitle" class="togglers"&gt;select&lt;/div&gt; &lt;div id="otherTitle2" class="togglers"&gt;ramsai&lt;/div&gt; </code></pre> <p>JS</p> <pre><code> $(function() { $('#title').change(function() { var divName = this.value; if(this.value == "All"){ $(".togglers").show(); }else{ $(".togglers").hide(); $("#"+divName).show(); } }); }); </code></pre> <p>This should do it. Bascially your select option values have to correspond to the div ID's. Then you do not need to go in and hardcode a show() or hide() rule for each one.</p>
 

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