Possible Duplicate:
change colors of table with javascript
for this problem im trying to change the whole table font color or background color depending on which cell is clicked (yellow cell turns all font in the table yellow…)
im pretty sure my syntaxis is correct but my logic sadly, isnt… can you guys point me in the right direction??
this is the code:
<html>
<script language="text/JavaScript">
function changeFont(color){
document.getElementById("miTabla").style.color = color;
}
function changeBack(color){
document.getElementById("miTabla").style.backgroundColor = color;
}
</script>
<body>
<header>Tabla de ejemplo</header>
<table id="miTabla" border="2">
<tr onclick="changeFont('red');">
<td>changeFont</td>
<td onclick="changeFont('#FF0000');">red</td>
<td onclick="changeFont('#FFFF00');">yellow</td>
<td onclick="changeFont('#0000FF');">blue</td>
</tr><tr>
<td>changeBack</td>
<td onclick="changeBack('#FFFFFF');">white</td>
<td onclick="changeBack('#808080');">gray</td>
<td onclick="changeBack('#000000');">black</td>
</tr>
</table>
</body>
</html>
1 Answer