-
-
Save dfparker2002/6a3f1ed9142b5e7d36c9bb49bb3a31f7 to your computer and use it in GitHub Desktop.
Demo on how to use the monitorEvents feature in Chrome Dev Tools
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"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Console - Monitor Events</title> | |
</head> | |
<body> | |
<header> | |
<h1>Using the Console to Monitor Events</h1> | |
</header> | |
<main> | |
<form id="myform"> | |
<label for="email">email: </label> <input type="email" id="email" /> | |
<button id="btnSend">Send</button> | |
</form> | |
<ul> | |
<li>Something to click</li> | |
<li>Something to click</li> | |
<li>Something to click</li> | |
<li>Something to click</li> | |
</ul> | |
</main> | |
<script> | |
document.addEventListener('DOMContentLoaded', () => { | |
//when the DOM is ready | |
document.querySelector('ul').addEventListener('click', listClicked); | |
document | |
.querySelector('form') | |
.addEventListener('submit', formSubmitted); | |
document.querySelector('#email').addEventListener('input', enteredText); | |
}); | |
window.addEventListener('load', () => { | |
//when the page loads | |
document.addEventListener('keypress', keypressed); | |
}); | |
function listClicked(ev) { | |
//list item clicked | |
} | |
function formSubmitted(ev) { | |
//button clicked to submit form | |
ev.preventDefault(); | |
} | |
function enteredText(ev) { | |
//user typed in the input fields | |
} | |
function keypressed(ev) { | |
//user hit a key | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment