Created
February 8, 2023 02:27
-
-
Save planetoftheweb/ea85601e7d437e8f4f37d44c1149d40b to your computer and use it in GitHub Desktop.
Example of the preventDefault method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" dir="ltr" data-theme="light"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Prevent Defaults</title> | |
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@1.*/css/pico.min.css"> | |
</head> | |
<body > | |
<main class="container"> | |
<h1>JavaScript Events</h1> | |
<article id="links"> | |
<a role="button" href="https://raybo.org">Blog</a> | |
<a role="button" href="https://youtube.com/@planetoftheweb">YouTube</a> | |
<a role="button" href="https://linkedin.com/in/planetoftheweb">LinkedIn</a> | |
</article> | |
</main> | |
<script type="text/javascript"> | |
document.getElementById("links") | |
.addEventListener("click", function (e) { | |
e.preventDefault(); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment