jQuery Set Select Value, Get Select Value : Update Dropdown List

2/16/2015 6:11:00 PM

Manipulate a SELECT input or dropdown list with jQuery. Get the value, get the text value, set the value, and append a new value.

//get the value
$("#myselect").val();


//get text value
$("#myselect option:selected").text();


//set select
$("#myselect").val(setToValue);
$("#myselect").val(1);


//append a new value
$('#mySelect')
         .append($("<option></option>")
         .attr("value", key)
         .text(value));