复选框选中复选框背景颜色并取消选中
我在gridview中有一个复选框,我想在检查时取消背景颜色并取消选中。
我使用jquery用于此目的,但它不起作用。
$(document).ready(function () { $('#checkboxAttendanceStatus').change(function () { alert('asdas'); $("#checkboxAttendanceStatus").css("backcolor", "green"); }); });
检查这个小提琴
HTML(样品):
JS:
$('#chk').on('change', function(){ if($('#chk').prop('checked')) $('#div').css('background', 'green'); else $('#div').css('background', 'red'); });
试试这个:
您也可以使用CSS的background-color
属性而不是background
,但background
优先于background-color
。
在你的答案中尝试这种方法。
$(document).ready(function () { $("#GridView1").children("tbody").find("tr").click(function () { if ($(this).attr("class") == "highlightedRow") { $(this).removeClass("highlightedRow"); } else { $(this).addClass("highlightedRow"); $(this).siblings("tr.highlightedRow").removeClass("highlightedRow"); } }).mouseover(function () { $(this).css("background", "Red"); }).mouseout(function () { $(this).css("background", ""); }); });
来源: https : //forums.asp.net/t/1701337.aspx?change+asp + gridview+row+backcolor+in+javascript+