select select option jquery code example

Example 1: set select option as selected jquery

$(document).ready(function() {
    $("#gate option[value='Gateway 2']").prop('selected', true);
    // you need to specify id of combo to set right combo, if more than one combo
});

Example 2: select option value jquery

$("select.country").change(function(){
  var selectedCountry = $(this).children("option:selected").val();
  alert("You have selected the country - " + selectedCountry);
});

Example 3: jquery selected option

$( "#myselect option:selected" ).val();

Example 4: jquery select option by value

$('.selDiv option[value="SEL1"]')

Example 5: jquery: get selected option of the drop down list

$('#ddlID').val();
$('#ddlID').text();

Example 6: jquery set select value

$("div.id_100 select").val("val2");

Tags:

Misc Example