我想更改特定單擊的表格行的背景顏色。它也應(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色。
單擊特定表格行時(shí)更改背景顏色
慕尼黑8549860
2021-10-21 13:58:42