[Solved] if statement around onclick


You’re going to want to make a reference to that element, so you don’t end up looking it up each time it’s clicked and you’ll need a variable to keep track of whether it’s been clicked or not:

var cancelButton = document.getElementById('btn_Cancel'),
    clicked = false;

cancelButton.addEventListener('click', function() { clicked = !clicked; }, false); 

// assuming this is in a loop or something:
if(!clicked) { 
    // running code 
}
else {
   // clicked, do nothing
}

1

solved if statement around onclick