Zyuzka,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script>
function test() {
var divs;
for (var j = 0; j < 6; j++) {
divs = document.getElementById('a' + j);
divs.onclick = function() {
var color = "blue"
for (var j = 0; j < 6; j++) {
divs = document.getElementById('a' + j);
divs.style.backgroundColor = color;
if (divs == this) color = '';
}
}
}
}
</script>
</head>
<body onload="test()">
<div id="a0">1</div>
<div id="a1">2</div>
<div id="a2">3</div>
<div id="a3">4</div>
<div id="a4">5</div>
<div id="a5">6</div>
</body>
</html>
|