Selecting an option using jquery - select box -


i'm trying update selected option in select box using jquery. html 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 change selected option default (first option) option value 3 (third option)?

thanks in advance

use .val()

$(document).ready(function() {    $('#selectbox').val('3') }); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -