You are viewing limited content. For full access, please sign in.

Question

Question

Check/uncheck a checkbox with JQuery

asked on October 10, 2014 Show version history

Hello,

I use a checkbox as a flag and while it can be manually set there are times I want to automatically uncheck it.

I gave the checkbox a class of "checkbox" and tried using both of the following with no success.

$('.checkbox').attr('checked', false);

$('.checkbox').prop('checked', false);

 

It may be related but I also had trouble checking the status of the checkbox with .attr and had to use $('.checkbox input').is(':checked') instead.

 

Thanks for any help!

0 0

Answer

SELECTED ANSWER
replied on October 11, 2014

You need to refer to it by field name/number, such as this for checking the first two items in a selection, and clears/removes the check from the third line

 

document.getElementById('Field3-0').checked = true;
document.getElementById('Field3-1').checked = true;
document.getElementById('Field3-2').checked = false;

 

 

1 0
replied on October 13, 2014

Thanks, that did it!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.