I need to set all select boxes to a particular value. Here’s the HTML:
<select>
<option value="-1"
<option value="55">ENABLE</option>
<option value="56">DISABLE</option>
<option value="57">HIDDEN</option>
</select>
There are eight such identical select boxes on the page.
What I want to do is, on a particular check box change, I need to set the values of all the select boxes to 55.
I have tried
$("input[type='select']").val('55');
and
$("input[type='select']").attr('selected','55');
But neither of them works. Can anyone suggest a workaround?
In your selectors you are trying to find an
<input>tag withtype="select"which is something that is not defined. Input tags could be of type text, radio, checkbox, submit, image, … What you have in the DOM is a<select>tag, so in order to set the value to 55 on all select elements in your page you could simply: