jQuery: The Write Less, Do More JavaScript Library

How to update check boxes in code

View: New views
2 Messages — Rating Filter:   Alert me  

How to update check boxes in code

by Arne Garvander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This code does not work
var chk = $('#frmCoverage:checkbox');
  chk.checked = true;

What am I doing wrong?

Re: How to update check boxes in code

by Karl Swedberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you are trying to set a dom property on a jQuery object.

for the second line, either do:

 chk[0].checked = true;

or: 

 chk.attr('checked', true);


--Karl

____________
Karl Swedberg




On Jul 2, 2009, at 3:45 PM, Arne Garvander wrote:


This code does not work
var chk = $('#frmCoverage:checkbox');
 chk.checked = true;

What am I doing wrong?