index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My JavaScript</title>
</head>
<body>
<form>
<input type="text">
<button>OK</button>
</form>
<p></p>
<script src="main.js"></script>
</body>
</html>
main.js
'use strict';
{
document.querySelector('form').addEventListener('submit', (e) => {
e.preventDefault();
document.querySelector('p').textContent = document.querySelector('input').value;
});
}