Skip to content

Attr: selectMultipleWithNoValue.val() now returns [] instead of null #828

Closed
@timmywil

Description

@timmywil

From jquery/jquery#2562

We have this line...

In the case of select elements, it returns null when no option is selected and an array containing the value of each selected option when there is at least one and it is possible to select more because the multiple attribute is present.

which could say something like this instead...

When called on select elements that have no option selected, the .val() method returns null, or an empty array if the multiple attribute is present. If at least one option is selected, either the value or an array of values will be returned.

Also, one of the examples will need editing.

Where we have...

var multipleValues = $( "#multiple" ).val() || [];

we can shorten it to...

var multipleValues = $( "#multiple" ).val();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions