0
In this code Onclick only works after the second click
<!DOCTYPE html>
<html>
<head>
<title>teste</title>
<style type="text/css">
div{
height: 100px;
width: 100px;
border: 5px solid blue;
opacity: 0;
}
</style>
</head>
<body>
<script type="text/javascript">
function vai(){
if (document.getElementById("div").style.opacity=="0") {
document.getElementById("div").style.opacity="1"
}
else {
document.getElementById("div").style.opacity="0"
}
}
</script>
<p onClick="vai()">aparece</p>
<div id="div">123</div>
</body>
</html>
document.getElementById("div").style.opacity="1" ? document.getElementById("div").style.opacity="1" : document.getElementById("div").style.opacity="0"
I think that solves, changes the conditionsif e else
for this reason– user76271
That didn’t work
– Soreze martins