JQuery select2 set default value from an option in list?
I want to be able to set the default/selected value of a select element using the JQuery Select2 plugin. One more way - just add a selected = "selected" attribute to the select markup and call select2 on it. It must take your selected value. No need for extra JavaScript. Like this : Markup <select class="select2"> <option id="foo">Some Text</option> <option id="bar" selected="selected">Other Text</option> </select> JavaScript $('select').select2(); //oh yes just this! See fiddle : http://jsfiddle.net/6hZFU/ Edit: (Thanks, Jay Haase!) If this doesn't work, try setting the val property of