Disable check boxes under the main div jquery
<div class="ex" id="baseTypes">
<table>
<tr>
<?php foreach ($transTypeList as $list) {
?><tr>
<td>
<input id="chkTransTypeBsn" style="vertical-align:baseline" name="chkTransTypeBsn[]" type="checkbox" value="<?php echo $list->trn_typ_code; ?>" />
</td>
<td width="100px;">
</td>
<td>
<in开发者_Go百科put id="chkBsnPreivous" style="vertical-align:baseline" name="chkBsnPreivous" type="checkbox" value="1" />
</td>
</tr>
<?php
?>
<?php
}
?>
</tr>
</table>
This is my code i want to disabled all the checkboxes onclick buttoon
my jquery is not working up to now any help
var checked = $("#ChkIsbsTxn").attr("checked");
if(checked){
$("#baseTypes : input").attr("disabled", true);
}else{
$("#baseTypes : input").attr("disabled", false);
}
In jQuery 1.6 you can do:
$("#baseTypes input:checkbox").attr("disabled", $("#ChkIsbsTxn").is(":checked"));
In older versions you would do
if($("#ChkIsbsTxn:checked").length){
$("#baseTypes input:checkbox").attr("disabled", "disabled"); // Disable
}else{
$("#baseTypes input:checkbox").remove("disabled"); // Enable
}
Try:
var checked = $("#ChkIsbsTxn").attr("checked");
if(checked){
$("#baseTypes input").attr("disabled", true);
}else{
$("#baseTypes input").removeAttr('disabled');
}
精彩评论