Note that there are some explanatory texts on larger screens.

plurals
  1. POchanging <select> options using jquery .change function
    primarykey
    data
    text
    <p>I'm facing this problem for more than 3 hours as I'm a still learning javascript and jquery.. I want to change select options based on user's choice from the same select input.. I don't know how to explain well but see this <a href="http://jsfiddle.net/YKASE/" rel="nofollow">http://jsfiddle.net/YKASE/</a></p> <p>THE HTML:</p> <pre><code>&lt;select name="test" class="select" id="test" multiple="multiple" style="width: 100%;"&gt; &lt;option value="1" class="first"&gt;1&lt;/option&gt; &lt;option value="2" class="first"&gt;2&lt;/option&gt; &lt;option value="3" class="first"&gt;3&lt;/option&gt; &lt;option value="a" id="1" class="hidden second"&gt;a&lt;/option&gt; &lt;option value="b" id="1" class="hidden second"&gt;b&lt;/option&gt; &lt;option value="c" id="1" class="hidden second"&gt;c&lt;/option&gt; &lt;option value="x" id="2" class="hidden second"&gt;x&lt;/option&gt; &lt;option value="y" id="2" class="hidden second"&gt;y&lt;/option&gt; &lt;option value="z" id="2" class="hidden second"&gt;z&lt;/option&gt; &lt;option value="baz" id="3" class="hidden second"&gt;baz&lt;/option&gt; &lt;option value="bar" id="3" class="hidden second"&gt;bar&lt;/option&gt; &lt;option value="foo" id="3" class="hidden second"&gt;foo&lt;/option&gt; &lt;/select&gt; </code></pre> <p>THE JS:</p> <pre><code>$("select#test").change(function () { $("#" + $(this).val()).removeClass("hidden"); $(".first").addClass("hidden"); }); </code></pre> <p>THE CSS:</p> <pre><code>.hidden { display: none; } </code></pre> <p>The problem is that only one option is shown but I want to show them all..</p>
    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.
 

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