What is e in e.preventDefault()

Viewed 1232

I am not able to understand the parameter 'e' which is passed to prevent the Default Action in JavaScript

document.getElementById('submit').addEventListener('click', calculate, false);
function calculate(e){
  e.preventDefault():
}
2 Answers

The e in e.preventDefault prevents the default action when a link is clicked, which is the page refreshing or changing. So it allows for behavior such as clicking on a link making a call to the database without a page refresh.

Here is a guide on the topic:

https://www.w3schools.com/jquery/event_preventdefault.asp

Related