Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Created October 19, 2021 19:26
Show Gist options
  • Save jdanyow/2ad3fa02e4e39e12aaed1a7158da9987 to your computer and use it in GitHub Desktop.
Save jdanyow/2ad3fa02e4e39e12aaed1a7158da9987 to your computer and use it in GitHub Desktop.
<!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