这就是我到目前为止所做的:-一个有20到30个单元格的表格-每个单元格都有一个复选框和一个值(当然是不同的值)-两个按钮来触发全选和全选复选框。
到目前为止的代码:-要触发,请选择全部/无:
Javascript:
function set_checked(checked) {
$('input[name=test]').attr('checked', checked);
}按钮:
onclick="set_checked(true)" and onclick="set_checked(false)" for both buttons.现在,如何在两个按钮上添加颜色更改?例如,当选择全部时,整个表格bg颜色变为绿色,而当选择无时,则变为白色。
发布于 2012-03-14 02:04:13
这应该做什么,需要做什么
function set_checked(checked) {
$('input:checked').attr('checked', checked); //select all checkbox
if(checked) {
$("table").css("backgroundColor", "#ddd"); //new color
} else {
$("table").css("backgroundColor", "#fff"); //old color
}
}发布于 2012-03-14 01:48:57
您可以使用.css更改背景颜色:
$("tableSelector").css("background-color","blue");发布于 2012-03-14 01:49:46
可能是这样的:
onclick="set_checked(true); $('table').css('background', 'green')"
onclick="set_checked(false); $('table').css('background', 'white')"https://stackoverflow.com/questions/9689247
复制相似问题