I'm dealing with the calling classes with document write. I defined two classes in CSS. First is "sahovnica" (chessboard) and second are "svetlo" (light) and "temno"(dark). With both classes I defined style for my table. And then I wanted to built a table with:
document.write( document.write('<td class="' + svetlo + '"></td>'););
Tried many different ways, but my code don't works. If I comment document.write(), page show up.
<!DOCTYPE html>
<html>
<head>
<title>Šahovska partija 2014</title>
<meta charset="UTF-8">
<style>
h1 {
color:blue;
font-family:verdana;
font-size:125%;
}
.sahovnica { border-spacing: 0; border-collapse: collapse; }
.sahovnica th { padding: .5em; }
.sahovnica td { border: 1px solid; width: 2em; height: 2em; }
.sahovnica .svetlo { background: #eee; }
.sahovnica .temno { background: #000; }
</style>
</head>
<body>
<table class="sahovnica">
<script>
var vrstica = parseInt(prompt("Vnesite številko vrstice", ""));
var stolpec = parseInt(prompt("Vnesite zaporedno številko stolpca", ""));
stolpec = stolpec -1
var value = vrstica + stolpec
value = value%2
if (value == 0) {
document.write( document.write('<td class="' + svetlo + '"></td>'););
}
else {
document.write( document.write('<td class="' + temno + '"></td>'););
}
</script>
</table>
</body>
</html>