var submits = document.querySelectorAll("input[type=submit]"); var i = 0; var f = function (e) { if (e.target.classList.contains("is_submitting")) { e.stopPropagation(); e.preventDefault(); } else { e.target.classList.add("is_submitting"); } }; for (i = 0; i < submits.length; i++) { submits[i].addEventListener("click", f); }