Skip to content
Browse files

Mention value attribute selector best practices

  • Loading branch information...
1 parent 561dffe commit c294190a91a76d225222d819b481ebae556da9d0 @gibson042 gibson042 committed Jan 16, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 warnings.md
View
2 warnings.md
@@ -91,7 +91,7 @@ $(document).ajaxStart(function(){ $("#status").text("Ajax started"); });
**Cause**: Prior to jQuery 1.9, `$().attr("value")` retrieved the value *property* instead of the value *attribute* (which generally reflects the value that was read from HTML markup). This caused inconsistent behavior with selectors referencing the value attribute.
-**Solution**: Use `$().val()` (for form controls) or `$().prop("value")` (for other elements) to get the *current* value.
+**Solution**: Use `$().val()` (for form controls) or `$().prop("value")` (for other elements) to get the *current* value, and try to explicitly limit the use of `[value=…]` in selectors to `input` and/or `option` elements wherever possible.
### JQMIGRATE: property-based jQuery.fn.attr('value', val) is deprecated

0 comments on commit c294190

Please sign in to comment.
Something went wrong with that request. Please try again.