-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Cannot set val()
for select options containing tabs (\t
)
#2978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, this bug fix seems responsible. Here's the PR and discussion. If we pull out that fix it seems like the code you're trying to use may not work on IE9 or 10, but then again we seem to have broken it consistently everywhere with this. |
Is it really broken, though? From what I see we do the same that Chrome/Firefox does with one exception that we return |
I think your fiddle is broken with respect to my comment (what's with the
Fixing this should consist of updating the |
I have a select element that contains options whose values contain tab characters. My original use case was a trailing tab (
string\t
), but I've also tested with leading tabs (\tstring
) and tabs in the middle of non-whitespace (str\ting
).I called
.val('value with tab')
on the select element and expected the corresponding option to be selected since the values are identical, but no option is selected.A few interesting observations:
.val()
, but this is unexpected since the values don't match exactly..val()
does not select the value, so there is no workaround for strings that have tab characters in the middle.JSFiddle: https://jsfiddle.net/onnucjx7/2/ You'll see in the console what I expect the behavior to be compared to what the behavior actually is.
I searched for "tab" and "whitespace" and didn't see anything directly relevant; I did find this issue #1902 but it only mentions IE10 and I am seeing the unexpected behavior in Firefox 44 and Chrome 48.
The text was updated successfully, but these errors were encountered: