Skip to main content

Bug Tracker

Side navigation

#10730 closed bug (invalid)

Opened November 09, 2011 04:49AM UTC

Closed November 09, 2011 01:21PM UTC

if checkbox is checked by jQuery, 'checked' attribute won't disappear when unchecking it manually

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:

The following code makes checkbox unable to correctly determine whether checkbox checked or not:

<script src='jquery-1.6.4.min.js'></script>
$(window).load(function() {
  $('#chk').attr('checked', 'checked');
  $('#test').click(function(e) {

<input id='chk' type='checkbox'>BadCheckbox
<button id='test'>Uncheck & press it to see</button>

So, after clicking on checkbox it will be unchecked, but 'checked' attribute will stay on it.

Attachments (0)
Change History (1)

Changed November 09, 2011 01:21PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

That is correct behavior. The user's click does not remove the attribute from the HTML. It only changes the property. If you want to know the dynamic state, use .prop("checked") instead.