从< td>获取attr('id').使用jQuery [英] Get attr('id') from a <td> using jQuery

查看:179
本文介绍了从< td>获取attr('id').使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,并且checkb从checkb01到chekb342.

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">&nbsp;</td>
     <td class="specs_under_value" id="specs_packageprice77">0.125</td>
</tr>

我尝试使用此代码

$(document).ready(function(){
    $(".checkb").toggle(function() {
        var cid = $(this).attr('id');
        alert('id');

    },function() {
        alert('checkbox unchekced');

    }

如何使用jquery在<td>相应的复选框点击中获取ID的值

How do I get the value of the id in <td> respective checkbox clicks using jquery

谢谢 吉恩

我需要在单击复选框时获取ID的值,而不是复选框ID

推荐答案

$(':checkbox').toggle(function() {
    var cid = $(this).attr('id');
    alert(cid);
}, function() {
    alert('checkbox unchekced');
}​);​

这篇关于从&lt; td&gt;获取attr('id').使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆