Hello i just want to ask you guys if you can help me with this problem: I need to write an javascript that writes out chess board like table, and that table must include onclick function that changes background color of that cell that is clicked on. I would really appreciate any help. This is what i got so far:
<html>
<head>
<title>Vaja 6.2</title>
<style type="text/css">
#table tr:nth-child(even) td:nth-child(odd),
#table tr:nth-child(odd) td:nth-child(even)
{
background-color: green;
}
</style>
<script type="text/javascript">
function enterSize()
{
x=prompt("Enter width:")
y=prompt("Enter height:")
for(var i=0; i<x; i++)
{
document.write("<table id=table border=1 cellpadding=0 cellspacing=0>")
document.write(" <tr>")
for (var j=0; j<y; j++)
{
document.write(" <td width=40 height=40>")
document.write(" </td>")
}
document.write(" </tr>")
document.write("</table>") }
}
</script>
</head>
<body >
<div><script>
enterSize();
</script></div>
</body>
</html>
Thanks