Created
October 19, 2021 19:26
-
-
Save jdanyow/2ad3fa02e4e39e12aaed1a7158da9987 to your computer and use it in GitHub Desktop.
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"> | |
<title>GistRun</title> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<h1>Hello world!</h1> | |
<form id="myForm"> | |
<input> | |
<textarea></textarea> | |
<button type="submit">submit</button> | |
</form> | |
<script> | |
console.log('Hello World!'); | |
myForm.addEventListener('submit', e => { | |
e.preventDefault(); | |
alert('submit'); | |
}); | |
myForm.addEventListener('keydown', e => { | |
if (e.key === 'Enter' && e.target.closest('input')) { | |
e.preventDefault(); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment