如何在点击父< tr>时更改Checkbox属性 [英] How to change a Checkbox attribute on click of parent <tr>

查看:96
本文介绍了如何在点击父< tr>时更改Checkbox属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的一点建议.

应更改内部复选框属性的单击.

Onclick of the checkbox attribute inside that should be changed.There is also a inside the

HTML代码:

 <table>
 <tr>
 <td class="answer"><input tabindex="4" type="checkbox" name="Dum1_4" id="Dum1_4" value="1"/></td>
 <td class="answerlabel"><label for="Dum1_4" id="Dum1_4_label"><table class="sample"><tr><td><img src="/ThumbsV2/2200000999-f.png"></td></tr><tr><td><b>Product 4</b></td></tr><tr><td>Product Description 4</td></tr><tr><td><b>Price 4</b></td></tr></table></label></td>
</tr>
<tr>
<td class="answer"><input tabindex="5" type="checkbox" name="Dum1_5" id="Dum1_5" value="1"/></td>
<td class="answerlabel"><label for="Dum1_5" id="Dum1_5_label"><table class="sample"><tr><td><img src="/ThumbsV2/2200001080-f.png"></td></tr><tr><td><b>Product 5</b></td></tr><tr><td>Product Description 5</td></tr><tr><td><b>Price 5</b></td></tr></table></label></td>
</tr>
</table> 

这是我的代码:

$('.sample').click(function()
{       
row =$this.parents("td");
row.siblings().find("input:checkbox").attr("checked","checked" );
}
});
});

请有人帮我!

推荐答案

$('TABLE > TBODY > TR').click(function()
{
    $('input:checkbox', $(this)).prop("checked", "checked");
});

这篇关于如何在点击父&lt; tr&gt;时更改Checkbox属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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