I’m trying to study for my exam and I thought I was doing this right…
I want to change the color of the table (font or background) depending on which cell you click
I thought I was referring to the table right, but this code isn’t working… I have no idea what I’m doing wrong, I’d appreciate any help or explanation you can offer
<html>
<script language="text/JavaScript">
function changeFont(color){
document.getElementbyId("miTabla").style.backgroundColor = color;
}
function changeBack(color){
document.getLementbyId("miTabla").style.font.color = color;
}
</script>
<body>
<header>Tabla de ejemplo</header>
<table id="miTabla" border="2">
<tr>
<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>
Change
getLementbyIdandgetElementbyIdtogetElementByIdand changefont.colortocolor.changeFontmight also be more appropriately namedchangeForeground.