I want to make it so that on a first click i call one function for javascript, and on a second click i call another function for javascript. How can that be?
Basically i press on this image, it calls this function, if i press it again it calls another function. First then second.
Using html
<script>
var clicked = false;
function doSomething()
{
if(clicked)
{
alert(2);
}
else
{
alert(1);
}
clicked = !clicked;
}
</script>
</head>
<body>
<p id="hello" onClick="doSomething();">Hello World</p>
</body>
See exmple here http://jsbin.com/uzivuj
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With