previous

page 2

next
index.html
<html>
<head>
<title>XXX</title>
<link rel='stylesheet' href='styles.css'>
<script src='functions.js'></script>
</head>
<body>
<div id='grid'>
<script>squares();</script>
</div>
</body>
</html>

You'll notice that I've decided to store all my functions in one file. This is how I usually work. I keep them in alphabetic order.

functions.js
function squares() {
var id=0;
var s1="<div id='";
var s2="' class='square' onClick='square_clicked(this);'></div>"
for (var r=0;r<3;r++) {
document.write("<div class='row'>");
for (var c=0;c<3;c++) {
document.write(s1+id+s2);
id++;
}
document.write("</div>");
}
}
previous
next