0

I'm studying the checkbox at jQuery UI.

Q: Why does clicking on the toggle button not toggle the "checked" attribute?

2
  • How are you verifying this? Could you provide some sample code exhibiting the problem? Commented Dec 7, 2011 at 21:22
  • I'm just using Firebug and examining the jQuery UI example in their documentation. Commented Dec 7, 2011 at 21:37

1 Answer 1

2

Just looking at Firebug isn't going to be enough to determine if the checked property on the relevant DOM element is set to true or false. In other words, just because the source viewer in Firebug doesn't show <input checked='checked' /> doesn't mean the checkbox isn't checked.

For the official explanation, check out the W3 link above. Under the documentation for the checked property, you'll see:

When the type attribute of the element has the value "radio" or "checkbox", this represents the current state of the form control, in an interactive user agent. Changes to this attribute change the state of the form control, but do not change the value of the HTML checked attribute of the INPUT element.

For the proper test, type the following in the console after clicking the button a few times:

$("#check").prop("checked");

Also, if you submit a form and the checkbox is a successful control, I promise the correct value of #check will be posted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.