Side navigation
#14654 closed bug (wontfix)
Opened December 26, 2013 09:59AM UTC
Closed December 26, 2013 04:05PM UTC
get select element value bug
Reported by: | frrru@163.com | 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
Attachments (0)
Change History (1)
Changed December 26, 2013 04:05PM UTC by comment:1
component: | unfiled → attributes |
---|---|
resolution: | → wontfix |
status: | new → closed |
.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.