Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery hide previous class based on current class
    text
    copied!<p>heres what im trying to do, pertty much i have a dropdown and i want that shows categories(level-0) and the subcategories (level-1). If there is sub categories, i want to hid the parent. Im using jquery but it is not doing what i need. </p> <p>Can anyone provide assistance.</p> <pre><code>&lt;ul class="chzn-results"&gt; &lt;li style="" class="active-result result-selected" id="cat_chzn_o_0"&gt;Select category&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_1"&gt;Amphibians&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_2"&gt;Arthropods&lt;/li&gt; &lt;li style="" class="active-result level-1" id="cat_chzn_o_3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Insects&lt;/li&gt; &lt;li style="" class="active-result level-1" id="cat_chzn_o_4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Scorpions&lt;/li&gt; &lt;li style="" class="active-result level-1" id="cat_chzn_o_5"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Spiders&lt;/li&gt; &lt;li style="" class="active-result level-1" id="cat_chzn_o_6"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Crustaceans&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_7"&gt;Birds&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_8"&gt;Fish&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_9"&gt;Fungi and Lichens&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_10"&gt;Mammals&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_11"&gt;Mollusks&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_12"&gt;Other&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_13"&gt;Plants&lt;/li&gt; &lt;li style="" class="active-result level-0" id="cat_chzn_o_14"&gt;Reptiles&lt;/li&gt; &lt;/ul&gt; jQuery(".chzn-results li.level-1").each(function(index, value) { jQuery(this).prevAll().hide(); }); </code></pre>
 

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