views:

35

answers:

4

I'm new to JQuery, i want to uncheck certain row in the repeater grid.

I got this work, this will uncheck all checkbox for me.

$('span.chkIncRows input').attr('checked', false);     

This works for me, if I want to uncheck row #2 checkbox from the repeater, without passing row number.

$('span.chkIncRows input')[2].checked =false;           

I don't know the syntax to uncheck the checkbox, if i want to pass in the row number into checkbox.

For example: I really want to do something like this, but it doesn't work.

$('span.chkIncRows input')[rowNumber].checked =false;  

Thanks advance for your help. Annie

+2  A: 

Use the :eq selector:

$('span.chkIncRows input:eq(1)').attr('checked', true);  

Note that it's zero-based, so input:eq(1) selects the second input.

SLaks
A: 

Try:

$('span.chkIncRows input').eq(2).attr('checked', false);

It's hard to say without knowing exactly what your HTML looks like. [edit] Also check @SLaks' answer; it depends on the context for the operation. The selector (':eq()') is handy but it means you have to glue the string together (which admittedly is not difficult).

Pointy
great!!! This works!$('span.chkIncRows input').eq(2).attr('checked', false);
Annie Chen
A: 
$('span.chkIncRows input').eq(2).attr('checked', 'checked');

should do it

Kind Regards

--Andy

jAndy
A: 

Use the eq selector: http://api.jquery.com/eq-selector/

$('span.chkIncRows input:eq(1)').attr('checked', false);

Andy Shellam