Side navigation
#8977 closed bug (invalid)
Opened April 26, 2011 01:26PM UTC
Closed April 26, 2011 02:46PM UTC
:checked attribute returning the first value, even after changes
Reported by: | <kantorvv@gmail.com> | Owned by: | <kantorvv@gmail.com> |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.6b1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
<input type="checkbox" checked="checked" id="sure"/> <input type="checkbox" id="unsure"/> <script> $('#sure,#unsure').change(function(){ console.log($('#sure').attr('checked'),$('#unsure').attr('checked')); }) //1.6b1 $("#unsure").trigger('change') // checked undefined $("#unsure").trigger('change') // checked undefined //1.5.2 $("#unsure").trigger('change') // true true $("#unsure").trigger('change') // true false </script>
Attachments (0)
Change History (2)
Changed April 26, 2011 02:00PM UTC by comment:1
component: | unfiled → attributes |
---|---|
owner: | → <kantorvv@gmail.com> |
status: | new → pending |
Changed April 26, 2011 02:46PM UTC by comment:2
priority: | undecided → low |
---|---|
resolution: | → invalid |
status: | pending → closed |
That is the correct behavior. This is something that was fixed in attr in 1.6 (removing the ambiguity). .attr('checked') retrieves the actual attribute (which correctly returns undefined as it does not exist on unsure) rather than the property. For DOM properties, use the .prop method. However, the preferred way to check if a box is checked, is with .is(':checked').
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists.