Side navigation
#9315 closed bug (duplicate)
Opened May 17, 2011 03:02PM UTC
Closed May 17, 2011 03:13PM UTC
Last modified March 14, 2012 06:08AM UTC
$('#myElement').attr('checked') does not work for checkbox inputs for Chrome
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | attributes | Version: | 1.6 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
Using jQuery 1.6.0 and Chrome 11.0.696.68, $('#myElement').attr('checked') is undefined when myElement is unchecked.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#cb').change(function () {
window.alert("value: " + $('#cb').attr('checked').toString());
});
});
</script>
</head>
<body>
<input type="checkbox" id="cb" name="cb" />
</body>
</html>
jsFiddle link to the code: http://jsfiddle.net/jDVcr/