Search
 
SCRIPT & CODE EXAMPLE
 

HTML

how to make a button not reload on click

<button id="button">Button</button> <!-->Creates a new button.</!-->
<script>
	const button = document.querySelector("#button"); //Finds the button by id.
	button.addEventListener("click", e => { //Runs the function (doesn't have to be an arrow function, just a function.) whenever said button is clicked.
      e.preventDefault(); //Stops said button from reloading the page.
    }
</script>
Comment

PREVIOUS NEXT
Code Example
Html :: empty link 
Html :: empty link javascript 
Html :: font awesome facebook icon 
Html :: get input value on button click javascript 
Html :: how to hide display in bootstrap 
Html :: html no drag image 
Html :: jsf axonivy composite 
Html :: how to put image center in html stack overflow 
Html :: how to show pdf as image in html 
Html :: how to navigate to another page in html 
Html :: how to break between characters in html 
Html :: html make space between buttons 
Html :: how to set an element affected by tab 
Html :: how to make circle button in bootstrap 
Html :: align right tailwind 
Html :: how to make dropdown in html 
Html :: how to make bootstrap cards centered 
Html :: load content of html without reloading python django 
Html :: javascript html reCAPTCHA 
Html :: embed tag youtube 
Html :: what is dir attribute in html 
Html :: bootstrap colored link 
Html :: input limit file type html 
Html :: bootstrap 4 tooltip 
Html :: twig default 
Html :: change icon html 
Html :: salesforce aura toggle input 
Html :: copyright html 
Html :: how to add a link to an image in html 
Html :: iframe with html string 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =