Bug Tracker

Modify

Ticket #9315 (closed bug: duplicate)

Opened 2 years ago

Last modified 15 months ago

$('#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:
Blocking: Blocked by:

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

comment:1 Changed 2 years ago by anonymous

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

comment:2 Changed 2 years ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to duplicate
  • Status changed from new to closed
  • Component changed from unfiled to attributes

comment:3 Changed 2 years ago by timmywil

Duplicate of #9191.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.