I have the following code, and the checkb starts from checkb01 to chekb342.
<tr>
<td class="specs_under">Specs</td>
<td id="checkb77" class='checkb'><input type="checkbox" id="add_remove77" class="change_image77"/></td>
<td class="specs_under_value" id="specs_unit77">1</td>
<td rowspan="13" class="specs_under_value" id="specs_itempr77">15</td>
<td class="specs_under_value" id="specs_quantity77"> </td>
<td class="specs_under_value" id="specs_packageprice77">0.125</td>
</tr>
I tried using this code
$(document).ready(function(){
$(".checkb").toggle(function() {
var cid = $(this).attr('id');
alert('id');
},function() {
alert('checkbox unchekced');
}
How do I get the value of the id in <td>
respective checkbox clicks using jquery
Thanks Jean
Guys I need to get the value of id when the checkbox is clicked, not the checkbox id
$(':checkbox').toggle(function() {
var cid = $(this).attr('id');
alert(cid);
}, function() {
alert('checkbox unchekced');
});
If you are trying to get the id of the enclosing td (not the checkbox itself) consider using the .closest() function.
ex:
$(':checkbox').change(function(){
var id = $(this).closest('td').attr('id');
alert(id + ' : ' + this.checked);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With