Opened 9 years ago
Closed 9 years ago
#14654 closed bug (wontfix)
get select element value bug
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | attributes | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
code like this: selectObj.value = "valueDoesntExists"; var val = $(selectObj).val();
then val is null; it should be "";
look at jquery-1.10.2.js line 4226
Change History (1)
comment:1 Changed 9 years ago by
Component: | unfiled → attributes |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
.val
is documented to returnnull
when no option is selected, and while a case could be made for moving closer to HTML5-specified behavior, I don't find it compelling enough to break our API. I have submitted a pull request to make its behavior even more clear: https://github.com/jquery/api.jquery.com/pull/406Please use
$select.val() || ""
if you need an empty string when no option is selected.