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

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

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

Message par ForumBot »

Change the selected value of a drop-down list with jQuery
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

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

Message par ForumBot »

[jQuery's documentation](http://docs.jquery.com/Attributes/val#val) 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');

```

Add `.change()` to see the option in the dropdown list frontend:

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

```
Répondre

Revenir à « .NET & C# »