Reputation: 109
this is what i have so far: - a table with 20 to 30 cells - each cell has 1 check box and a value (different value of course) - two button to trigger select all and select none checkboxes.
Codes so far: - to trigger select all/none:
Javascript:
function set_checked(checked) {
$('input[name=test]').attr('checked', checked);
}
buttons:
onclick="set_checked(true)" and onclick="set_checked(false)" for both buttons.
now, how do i add color change on both buttons? for example, entire table bg color change to green when select all and change to white when select none.
Upvotes: 0
Views: 168
Reputation: 79031
This should do, what is needed
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
}
}
Upvotes: 1
Reputation: 101143
Maybe something like this:
onclick="set_checked(true); $('table').css('background', 'green')"
onclick="set_checked(false); $('table').css('background', 'white')"
Upvotes: 0
Reputation: 78710
You can use .css
to change background color:
$("tableSelector").css("background-color","blue");
Upvotes: 1