When you select the first field, the second value changes. But when you first open the page, in the second field, it should be the default only "Select model", and I display all the values. After I choose the second or third, everything gets better. What is the glitch? Even selected added does not help.
<select name="first" id="first"> <option value="one" selected>Выберите марку</option> <option value="two">BMW</option> <option value="tri">Audi</option> </select> <select name="second" id="second"> <option value="one" class="one" selected>Выберите модель</option> <option value="two" class="two">Второй 1</option> <option value="two" class="two">Второй 2</option> <option value="two" class="two">Второй 3</option> <option value="tri" class="tri">третий</option> <option value="tri" class="tri">третий 2</option> </select> <script> $('#first').change(function(){ var cls = $(this).val(); $('#second option').hide(); $('#second ' + '.' + cls).show(); }); </script>
hideoccurs only after change of the first. - olegatro<style>.two { display: none; } .tri { display: none; }</style><style>.two { display: none; } .tri { display: none; }</style>- Igor