Source Code:
(back to article)
Submit
Result:
Report an issue
<a href="https://www.example.com" id="myLink">Go to Example.com</a> <script> document.getElementById('myLink').addEventListener('click', function(event) { event.preventDefault(); // Stops the default link behavior alert('Default action prevented! Link will not open.'); }); </script>