Get attr ('id') from <td> using jQuery
I have the following code and checkb starts with checkb01 on 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 to get id value in <td>corresponding checkboxes using jquery
Thanks jean
Guys I need to get the id value when I click on the flag, and not on the id flag
+5
5 answers
, (toggle() , change() ):
$('.checkb :checkbox').change(function(){
if(this.checked){
// Do somethin'
alert(this.id);
} else {
// Do something else
alert('Unchecked!');
}
});
toggle, :
$(".checkb").toggle(function() {
var cid = $(this).children(':checkbox').attr('id');
alert(cid);
}, function() {
alert('checkbox unchekced');
});
- .
+1
, , - rel id tr, :
<tr id="row77">
<td class="specs_under">Specs</td>
<td id="checkb77" class='checkb'><input type="checkbox" id="add_remove77" class="change_image77" rel="row77"/></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>
:
<script type="text/javascript">
$('checkbox:checked').each(function() {
var id = $(this).attr('rel').substr(3,$(this).attr('rel').length); // 77
var specs_packageprice = $('#'+$(this).attr('rel')+' #specs_packageprice'+id).html(); //0.125
// More code...
}
</script>
, ...
+1