You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is a problem in jQuery 1.9.0+ as the selector of value is not taking into account the value set by the val function of jQuery.
I'm not sure that it's by design or not, but it seems like a bug.
If you set a value of a text box via $("input:text").val("newValue") then the selector of jQuery is not taking this change into account.
So the $("input:text[value='newValue']") returns nothing.
However, when a selector like "input[value=abc]" is used, it should always select by the value attribute and not any change made to the property by the user, for example from them typing into a text input. As of jQuery 1.9, this behaves correctly and consistently. Earlier versions of jQuery would sometimes use the property when they should have used the attribute.
If you want to find an input with a concrete value you may limit the selection via filter:
Also, make sure you don't use the :text part if this code is executed very often for performance reasons, this makes the whole selector skip the native querySelectorAll.
@mgol Thanks a lot for your clear explanation and sorry for the misunderstanding, I searched a lot, but didn't see this note before. Thanks for clarification.
lockbot
locked as resolved and limited conversation to collaborators
Jun 18, 2018
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I think there is a problem in jQuery 1.9.0+ as the selector of value is not taking into account the value set by the val function of jQuery.
I'm not sure that it's by design or not, but it seems like a bug.
If you set a value of a text box via $("input:text").val("newValue") then the selector of jQuery is not taking this change into account.
So the $("input:text[value='newValue']") returns nothing.
You can check the difference in the following links:
jQuery 1.9+:
https://jsfiddle.net/fghamsary/13v7kobL/2/
jQuery 1.8.3-:
https://jsfiddle.net/fghamsary/13v7kobL/3/
Normally I would expect change with .val function to be reflected on the value attribute of the input as well. (Which seems reasonable)
The text was updated successfully, but these errors were encountered: