微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

JQuery点击行tr实现checkBox选中的简单实例

<div class="jb51code">
<pre class="brush:js;">
$(function () {

//除了表头(第一行)以外所有的行添加click事件.

$("tr").first().nextAll().click(function () {

//为点击的这一行切换样式bgRed里的<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>:background-color:#FF0000;

$(this).children().toggleClass("bgRed");

//判断td<a href="https://www.jb51.cc/tag/biaoji/" target="_blank" class="keywords">标记</a>的背景颜色和body的背景颜色是否相同;

if ($(this).children().css("background-color") != $(document.body).css("background-color")) {

 //如果相同,Check<a href="https://www.jb51.cc/tag/Box/" target="_blank" class="keywords">Box</a>.checked=true;

 $(this).children().f<a href="https://www.jb51.cc/tag/irs/" target="_blank" class="keywords">irs</a>t().children().attr("checked",true);



} else {

 //如果不同,Check<a href="https://www.jb51.cc/tag/Box/" target="_blank" class="keywords">Box</a>.checked=false;

 $(this).children().f<a href="https://www.jb51.cc/tag/irs/" target="_blank" class="keywords">irs</a>t().children().attr("checked",false);

}

});

});

以上这篇JQuery点击行tr实现checkBox选中的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。

原文地址:https://www.jb51.cc/jquery/48444.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐