i was trying to check uncheck all option of checkboxlist programmatically but my code is not working. here is snippet
$(document).ready(function () {
$('#myLink').click(function () {
$("INPUT[id^='chkFileds']").attr('checked', $('#chkFileds').is(':checked'));
});
});
what is wrong in my code. i want that when user click on check hyperlink then all option of checkbox list will be checked and when click again on the same link then all option of checkbox list will be uncheck. please guide me how to do it. thanks
UPDATE:
thanks for ur answer but i am not talking about check rather checkbox list what has many checkbox inside.it looks like....he i am giving the html of checkboxlist
<table style="font-weight:bold;" id="chkCountry">
<tbody>
<tr>
<td>
<input type="checkbox" value="GB" name="chkCountry$0" id="chkCountry_0">
<label for="chkCountry_0">UK</label>
</td>
<td>
<input type="checkbox" value="US" name="chkCountry$1" id="chkCountry_1">
<label for="chkCountry_1">USA</label>
</td>
</tr>
</tbody>
</table>
$("INPUT[id^='chkFields']"). In addition, what does$('#chkFileds')refer to?