I have an select box:
<select id="selectBox"> <option value="0">Number 0</option> <option value="1">Number 1</option> <option value="2">Number 2</option> <option value="3">Number 3</option> <option value="4">Number 4</option> <option value="5">Number 5</option> <option value="6">Number 6</option> <option value="7">Number 7</option> </select> I'd like to set one of the options as "selected" based on it's selected index.
For example, if I am trying to set "Number 3", I'm trying this:
$('#selectBox')[3].attr('selected', 'selected'); But this doesn't work. How can I set an option as selected based on it's index using jQuery?
Thanks!