On resize I want the code to run the first if statement: "I think this is too small". On the second resize I want it to run the first alternate: "I think this is too big". It only runs one, is it because the variable adjustment is local only and doesn't stick around for the second time?
var counter = 0;
function message() {
if (counter == 0) {
document.write("I think this is too small");
counter = counter + 1;
} else if (counter == 1) {
document.write("I think this is too big");
counter = counter + 1;
} else {
confirm("Third Time's a charm");
}
}
window.addEventListener('resize', message, false);
<p>Text</p>