Side navigation
#13895 closed bug (duplicate)
Opened May 15, 2013 03:30AM UTC
Closed May 15, 2013 01:26PM UTC
Error in chage input:checkbox
Reported by: | juanpa_842@hotmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Current version 1.9.1
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script type="text/javascript"> function set_checked(value) { $('input[name=foo]').attr('checked', value); } function show_checked() { alert($('input[name=foo]').is(':checked')); } </script> </head> <body> <form> <input type="checkbox" name="foo" value="bar"> <input type="button" onclick="show_checked()" value="Show"> <input type="button" onclick="set_checked(true)" value="On"> <input type="button" onclick="set_checked(false)" value="Off"> </form> </body> </html>
Attachments (0)
Change History (3)
Changed May 15, 2013 04:51AM UTC by comment:1
Changed May 15, 2013 09:24AM UTC by comment:2
Hi,
This is not a bug. You should use prop method instead of attr.As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.
Kind regards,
Jorgebg
http://jsfiddle.net/martinezbohorquez/RcF6p/