Thursday, June 27, 2013

How to set and get selected value in dropdown list by jQuery

Set selected value:
var selectstring = 'select option[value="' + selectedValue + '"]';
$(selectstring).attr('selected', true);

Get selected value:
$("#dropdownlistId").change(function () {
alert($("#dropdownlistId").val());
});