Try this out:

$("#chkList input:checkbox").attr("checked",true);

This says: "get all input fields of type checkbox, within table id 'chkList', and set attribute checked of those inputs to true."

You don't need to use the method "each" because jQuery will automatically iterate over the returned elements.

-- Josh


----- Original Message ----- From: "AzamSharp" <[EMAIL PROTECTED]>
To: "jQuery (English)" <jquery-en@googlegroups.com>
Sent: Saturday, May 10, 2008 9:54 AM
Subject: [jQuery] Selecting Checkboxes inside the table



I am having trouble to check the checkboxes contained inside the HTML
table.

Here is the table code:

<table id="chkList" border="0">
<tr>
<td><input id="chkList_0" type="checkbox" name="chkList$0" /><label
for="chkList_0">Item 1</label></td>
</tr><tr>
<td><input id="chkList_1" type="checkbox" name="chkList$1" /><label
for="chkList_1">Item 2</label></td>
</tr><tr>
<td><input id="chkList_2" type="checkbox" name="chkList$2" /><label
for="chkList_2">Item 3</label></td>
</tr>
</table>

I am using the following code to check all the checkboxes but it does
NOTHING!

 ($("#chkList").children({"input":"checkbox"}).each(function()
      {

           this.checked = true;
}));

Reply via email to