源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2020-09-13 23:21 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JQuery点击行tr实现checkBox选中的简单实例
$(function () {

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

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

    //为点击的这一行切换样式bgRed里的代码:background-color:#FF0000;

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

    //判断td标记的背景颜色和body的背景颜色是否相同;

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

     //如果相同,CheckBox.checked=true;

     $(this).children().first().children().attr("checked", true);

 

    } else {

     //如果不同,CheckBox.checked=false;

     $(this).children().first().children().attr("checked", false);

    }

   });

  });
以上这篇JQuery点击行tr实现checkBox选中的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部