Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#9315 closed bug (duplicate)

$('#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>

Change History (3)

comment:1 Changed 8 years ago by anonymous

jsFiddle link to the code: http://jsfiddle.net/jDVcr/

comment:2 Changed 8 years ago by timmywil

Component: unfiledattributes
Priority: undecidedlow
Resolution: duplicate
Status: newclosed

comment:3 Changed 8 years ago by timmywil

Duplicate of #9191.

Note: See TracTickets for help on using tickets.