make a button work in different ways in odd and even clicks

M

Marco Molinari

Guest
I know my question might have been asked a milion times but I am really stuck even after 4 hours of research; what I would like to do is geting an onclick function over an image to work differenly in odd and even clicks:

<div class= "random button" onclick = "myFunction()">
<img class="cool image">
</div>
<div class = "very cool content">
<p>lorem</p>
</div>

function myFunction () {
var x = 0;
if (x - math.floor(x) = 0) {
document.getElementByClass("very cool content").style.display = "grid";
var x = x + 0.5;
} else {
document.getElementByClass("very cool content").style.display = "none";
var x = x + 0.5;
}


I know this question is very stupid but I am absolutely incompetent in javascript and I wasn't able to implement any of the answers I founded online so please help me.

Continue reading...
 
Top