Change the selected value of a drop-down list with jQuery Change the selected value of a drop-down list with jQuery asp.net asp.net

Change the selected value of a drop-down list with jQuery


jQuery's documentation states:

[jQuery.val] checks, or selects, all the radio buttons, checkboxes, and select options that match the set of values.

This behavior is in jQuery versions 1.2 and above.

You most likely want this:

$("._statusDDL").val('2');


With hidden field you need to use like this:

$("._statusDDL").val(2);$("._statusDDL").change();

or

$("._statusDDL").val(2).change();


Just an FYI, you don't need to use CSS classes to accomplish this.

You can write the following line of code to get the correct control name on the client:

$("#<%= statusDDL.ClientID %>").val("2");

ASP.NET will render the control ID correctly inside the jQuery.