I'm extremely new to code writing, so please forgive any ignorance on my part. I have a simple bit of code in which I would like to make the visibility of a couple of "outerCircle" divs turn off when the user clicks anywhere on the page. I have tried several ways, but it's just not working. If anyone has a suggestion, I would greatly appreciate it. Here is what I have so far:
<body onload = "startBlink()" onclick = "onOff()">
<p id = "title">Click anywhere to turn the outer circles on or off.</p>
<div class = "container" onclick = "onOff()">
<div class = "outerCircle" id = "outerLeftCircle">
<div class = "innerCircle" id = "innerLeftCircle">
</div>
</div>
<div class = "outerCircle" id = "outerRightCircle">
<div class = "innerCircle" id = "innerRightCircle">
</div>
</div>
</div><!-- Closes the container div -->
<script>
// This function blinks the innerCircle div //
function startBlink(){
var colors = ["white","black"];
var i = 0;
setInterval(function() {
$(".innerCircle").css("background-color", colors[i]);
i = (i+1)%colors.length;
}, 400);
}
// This function turns the outerCircle divs on or off //
function onOff() {
alert("Entering function now");
if (getElementById(".outerCircle").style.visibility = "visible") {
getElementById(".outerCircle").style.visibility = "hidden";
getElementById(".outerLeftCircle").style.visibility = "hidden";
getElementById(".outerRightCircle").style.visibility = "hidden";
} else {
getElementById(".outerCircle").style.visibility = "visible";
getElementById(".outerLeftCircle").style.visibility = "visible";
getElementById(".outerRightCircle").style.visibility = "visible";
}
}
</script>