在同级< td>中找到复选框并使用jQuery检查它 [英] Find the Checkbox in Sibling <td> and check it using jQuery

查看:67
本文介绍了在同级< td>中找到复选框并使用jQuery检查它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $('.answerlabel').click(function()
  {
  $(this).siblings('.answer').find('input:checkbox').attr("checked","checked");
  });

"answer"是一个类,"answerlabel"是另一个类.两者将在同一个类中,但是不起作用.

There "answer" is one class and "answerlabel" another class.Both will be in same .But it is not working.

任何建议.. 这是我的HTML代码

Any suggestions.. Here is my HTML Code

 <table>
 <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="http://bizbox.slate.com/blog/google.jpg"></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>

推荐答案

尝试此操作以获取功能:

Try this to get the functionality:

$('.answerlabel label').click(function(){
    $(this).parents('.answerlabel:first').siblings('.answer').find('input:checkbox').attr("checked","checked");
});

这篇关于在同级&lt; td&gt;中找到复选框并使用jQuery检查它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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