Clicking a link and submitting a form will, by default, take you to another page. In some cases, you may want to override that behavior.
The following example shows how to prevent both links and forms from taking the user away from the current page:
In this example, we use the <a> tag’s “onclick” attribute and the <form> tag’s “onsubmit” attribute to handle user click and submit events, respectively. By telling the code to “return false;” when a user clicks a link or submits a form, we tell the browser to prevent that element from performing its default behavior.