Consider an HTML table with multiple rows having radio button in first column of each row. Now, if we want to change the row color when radio button associated with it is clicked, we have to write following code.
// HTML //
Untitled
// CSS //
body {
margin:10px; padding:0px;
background:#fff;
}
td {
border-style: solid;
border-width: 1px;
font-size:15px;
padding:5px;
text-align:center;
}
.radiotd{width:15px}
// Java Script //
function setrow(row) {
// Clear all rows each time
for (i=1; i<5; i++) {
var elem = 'r' + i;
document.getElementById(elem).style.background = "#fff";
}
// set desired row
document.getElementById(row).style.background = "#ddd";
return true;
}
0 Comment(s)