Opened 10 years ago
Closed 10 years ago
#13895 closed bug (duplicate)
Error in chage input:checkbox
Reported by: | 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>
Change History (3)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
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
Note: See
TracTickets for help on using
tickets.
http://jsfiddle.net/martinezbohorquez/RcF6p/