iam having the select box
<select id ="myselect">
<option value="AA">AA</option>
<option value="AB">AB</option>
<option value="AC">AC</option>
<option value="AD">AD</option>
</select>
so on document load I want to Make item "AC" in the select box as the default selected option on loading the document
$('#myselect').children('option').text('AC').attr('selected', 'selected');
so with this statement written it is making my select box to fill with values 'AC' completely for my select box. How do i correct that and i tried in using the if statement comparing the value for 'AC'.And i dont have the "Value" for option as number
It should be do-able with:
$('option[value=AC]').attr('selected','selected');
Demo at: jsbin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With