I'm having problems creating a global variable and resetting it through jquery. here is my code
var x = 1;
$(document).ready(function () {
$("#button").click(function () {
if(x === 1) {
alert("test1");
var x = 2;
} else if(x === 2) {
alert("test2");
var x = 3;
} else {
alert("test 3");
}
});
});
I want to be able to click the same button three times and have all the tests appear, but instead it goes straight to the last option "test 3"
. I apologize if this is a silly question, but I'm a bit new to jquery and javascript.