#8512 closed enhancement (patchwelcome)
jQuery("SELECT").val(null) : inconsistent results in different browsers
Reported by: | shehriyari | Owned by: | shehriyari |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
Please run it on the latest versions of all browsers, and see for yourself. When the button is clicked, on:
- on WebKit browsers (Chrome, Safari) it just doesn't select anything, instead creates some ghostly empty option
- on Firefox and Opera, it works the way I expect and want it to work, de-selects all options of the element
- on Explorer, it does nothing
jQuery 1.5.1 source code also tells us that, in this case jQuery sets selectedIndex = -1.
But since browsers mess it up in this case. Shouldn't jQuery force it to behave the way Firefox and Opera does, de-select all child options?
Thanks.
Change History (3)
comment:1 Changed 12 years ago by
Component: | unfiled → attributes |
---|---|
Owner: | set to shehriyari |
Priority: | undecided → low |
Status: | new → pending |
Type: | bug → enhancement |
comment:2 Changed 12 years ago by
Status: | pending → new |
---|
I would prefer that, yes, to select no options.
HOWEVER, my wishes are irrelevant: Although it is NOT documented, the CODE is written that way [jQuery source 1.5.1 - check the stackoverflow.com discussion I referred you to, in original report]. What I say, is that you should make a decision, and implement it. Having selectedIndex = -1 doesn't solve problems, it creates them. jQuery's primary objective (I believe) should be "to be standards-compliant AND cross-browser, useful tool that DOES function", not just "to be standards-compliant tool that follows those standards blindly, to no end". selectedIndex = -1 doesn't serve anyone...
And again, YES, I would recommend having all options de-selected. That would solve a lot of problems and would be quite useful shortcut for us, developers.
Thanks for all the effort you guys putting forward, jQuery is an awesome tool! Good luck!
P.S.: That's why I would call this report a BUG, not an ENHANCEMENT, since this little feature doesn't do anything useful for front-end designers.
comment:3 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Resolution: | → patchwelcome |
Status: | new → closed |
There is no documented behavior for
.val(null)
, are you asking for that to be an enhancement to select no options then? The W3C has this to say about the case where nothing is selected initially:http://www.w3.org/TR/html401/interact/forms.html#h-17.6
It's not clear whether browsers want you to deselect all options on a select-one element, but the behavior seems to be poorly defined in any case.