Last active
September 3, 2019 23:02
-
-
Save masautt/c371f6ad001e3cd5111019ac897c1f0f to your computer and use it in GitHub Desktop.
How to prevent submit button from refreshing page when clicked using JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById("myBtn").addEventListener("click", e => { | |
//some code | |
e.preventDefault(); //This specifically removes the default behavior of refreshing the page | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment