Hi there, first time posting so please forgive me if I break etiquette 🙂
I’m playing around with making a circle appear and disappear when it’s clicked – I wrote an If/Else statement to see if I’d got the first step right and I obviously haven’t because something isn’t working! I’m not getting any errors in the console though – it’s just saying No when I’m expecting it to say Yes.
Can anyone tell me what I’ve done wrong? I’m sure it’ll be glaringly obvious to everyone else but I just cannot see it!
Thanks!
[code]
<html>
<head>
<title>Javascript</title>
<style type=”text/css”>
.circle {
height: 100px;
width: 100px;
border-radius: 50%;
border-width: 0px;
display: inline-block;
background-color: purple;
opacity: 1;
}
</style>
</head>
<body>
<div id=”circle1″ class=”circle”></div>
<script type=”text/javascript”>
document.getElementById(“circle1”).onclick = function() {
if (document.getElementById(“circle1”).style.opacity == 1) {
alert(“Yes”);
}
else {
alert(“No”);
}
}
</script>
</body>
</html>