On the first click of my button (#nextbtn) I want the function (nextClicked()) to run (but only the part specified in the if statement: if clickCount === "1") and on the second click I want the same function to run, from the second if statement. However, the code runs through the first if statement on the first onclick, but if you cick the button again it just repeats this, instead of goinon to the second if statement. There must be something wrong with my javascript. (Note: I haven't put else because I want to add more parts to the function later on) HTML for the buttton:
<button id="nextbtn" onclick="nextClicked()">NEXT</button>
JS:
function nextClicked() {
var clickCount === "1"
var next = document.getElementById("nextbtn")
if (clickCount === "1") {
next.style.marginTop = "10"
}
if (clickCount === "2") {
next.style.marginTop = "20"
}
}
Aucun commentaire:
Enregistrer un commentaire