Skip to content

Instantly share code, notes, and snippets.

@dsomel21
Created June 17, 2016 04:38
Show Gist options
  • Save dsomel21/4c54a2ea67d085b7b436aa9dd9d47ff8 to your computer and use it in GitHub Desktop.
Save dsomel21/4c54a2ea67d085b7b436aa9dd9d47ff8 to your computer and use it in GitHub Desktop.
DOM Events
$(document).ready(function(){
/* Listening for keypress events on the firstname input box */
$("#fname").keypress(function(event){
switch(event.which){
case 65:
console.log("[SHIFT] + [A]")
break;
case 16:
console.log("[SHIFT]")
break;
default:
console.log("N/A");
break;
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DOM Events</title>
</head>
<body>
<div>
<h1 id="top">Richard</h1>
<h4 id="cool">Cool Guy</h4>
<h4 id="teacher">Career</h4>
<h4 id="business">Bidniss</h4>
</div>
<img src="https://secure.gravatar.com/avatar/1e3b7cfade9fee4a73163f600044762a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0015-72.png%27" alt="ram">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="app.js" id="cool_image"></script>
<h2>send him an email!</h2>
<form id="form">
First name: <input type="text" name="fname" id="fname"><br>
Last name: <input type="text" name="lname" id="lname"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment