Skip to main content

Bug Tracker

Side navigation

#13716 closed bug (duplicate)

Opened April 03, 2013 02:18AM UTC

Closed April 03, 2013 02:28AM UTC

checkbox attr/removeAttr problems

Reported by: calmhawk@126.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.0
Keywords: Cc:
Blocked by: Blocking:
Description

I believed the bug is involved with the version 1.9.0.

Here is a simple example:

<html>

<head>

<script src="./jquery-1.9.0.js" type="text/javascript"></script>

</head>

<body>

<input id="test" type="button" value="click">

<fieldset>

<input class="test" type="checkbox" value="a">

<input class="test" type="checkbox" value="b">

<input class="test" type="checkbox" value="c">

<input class="test" type="checkbox" value="d">

<input class="test" type="checkbox" value="e">

</fieldset>

</body>

<script>

$("#test").click(function(){

$(".test").each(function(){

if($(this).attr('checked'))

$(this).removeAttr('checked');

else

$(this).attr('checked', 'checked');

});

});

</script>

</html>

Here are the steps:

1. Click the button, all the elements are checked.

2. Click again, no checked.

3. Click again, the attribute 'checked' is absolutely added, but the box is not checked.

The versions after 1.8.3 have the problem, but the version 1.8.3 is ok.

Attachments (0)
Change History (1)

Changed April 03, 2013 02:28AM UTC by m_gol comment:1

resolution: → duplicate
status: newclosed

Duplicate of #13667.Use prop(), not attr() for this.