Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Select multiple will return null when no values returned #2562

Closed
@ghost

Description

I've just been looking into an issue whereby if you have aselect element with themultiple option set and no options selected$().val() will returnnull rather than an empty array. If one more more items are selected, then it returns an array. I would have expected that an empty array would have been returned in this case.

This fiddle shows the issue. IT appears all the way back to jQuery 1.2 where multiple value support was added.

The reason an empty array is not returned is the check forelem.selectedIndex being < 0here. While I understand that for a single select, I don't while get why that would be done for a multi-select.

Removing|| index < 0 would allow the empty array to be returned.

Having said that, I'm not really expecting this change to be made as I guess a number of sites will depend upon this behaviour. I'm more wondering if someone might be willing to say why it is done this way? I've searched this issue tracker and the bugs.jquery.com site, but couldn't find any mention of it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp