第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

單擊特定表格行時(shí)更改背景顏色

單擊特定表格行時(shí)更改背景顏色

慕尼黑8549860 2021-10-21 13:58:42
我想更改特定單擊的表格行的背景顏色。它也應(yīng)該把它改回原來的顏色。從紅色到綠色來回。它還應(yīng)該選中復(fù)選框。綠色 = 復(fù)選框已選中/紅色 = 復(fù)選框未選中。行看起來像這樣 <tr id="<?php echo $row['id'] ?>" value="<?php echo $row['id'] ?>">對(duì)于 JQUERY 我有這個(gè):$(document).ready(function() {    $('.table tr').click(function(event) {        var id = $(this).attr('id');        var bcolor = $('.task').css('background-color');        console.log(id);        console.log(bcolor);if (event.target.type !== 'checkbox') {            $(':checkbox', this).trigger('click');            if (bcolor == 'rgb(205, 92, 92)') {                $('.task').css('background-color', 'green');            } else {                $('.task').css('background-color', 'indianred');            }        };    });});如何使用var id = $(this).attr('id');僅更改特定單擊行的背景顏色?現(xiàn)在,它通過單擊其中任何一行使每一行變?yōu)榫G色。
查看完整描述

2 回答

?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

您可以使用 jQuery 的 toggleClass:


// css for put in your element

.common-class {

    background-color: #ff0000; // replace for your color

}


.highlight-class {

    background-color: #0000ff !important; // replace for your color

}


$('your-selector').toggleClass('highlight-class'); // jQuery


查看完整回答
反對(duì) 回復(fù) 2021-10-21
  • 2 回答
  • 0 關(guān)注
  • 206 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)