<html>
<body>
<a id="myAnchor" href="https://w3schools.com/">Go to W3Schools.com</a>
<p>The preventDefault() method will prevent the link above from following the URL.</p>
<p>Click the link and check if the default action is prevented.</p>
<script>
document.getElementById("myAnchor").addEventListener("click", function(event){
event.preventDefault()
alert("Was preventDefault() called: " + event.defaultPrevented);
});
</script>
</body>
</html>