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

时间:2016-05-26    点击:91   
$(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选中的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持本站。

jquery获取复选框的值的简单实例
改变checkbox默认选中状态及取值的实现代码
jquery获取复选框checkbox的值的简单实现方法
jquery判断checkbox是否选中及改变checkbox状态的实现方法
jquery获取所有选中的checkbox实现代码
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved