$(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選中的簡單實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。
新聞熱點
疑難解答