0

Why my jquery object didn't get checked with $('.checkall').checked = true ;
Here's a Fiddle.
UPDATE : working code

3 Answers 3

4

This is a problem of mixing jQuery, and DOM, methods. jQuery doesn't have access to the .value property of the node, instead use:

$('.checkall').prop('checked',true);

Reference:

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

Comments

3

You need this:

$('.checkall').prop('checked',true);

Or:

$('.checkall')[0].checked = true ;

You would use .prop() to set the property of checked or directly covnert the jQuery element to HTMLElement and then directly set the value.

Comments

3

Use .prop()

$('.checkall').prop('checked',true)

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.