0

I'm trying to update the selected option in a select box using jQuery. My html is as follows:

<select id="selectBox">
    <option value="1">Value 1</option>
    <option value="2">Value 2</option>
    <option value="3">Value 3</option>
    <option value="4">Value 4</option>
</select>

Using jQuery, how can I change the selected option from the default (first option) to the option with value 3 (third option)?

Thanks in advance

1

1 Answer 1

2

Use .val()

$(document).ready(function() {
   $('#selectBox').val('3')
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.