<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Momentum App</title>
<link rel="stylesheet" href="Momentum.css">
</head>
<body>
<form id="login-form">
<input
required
maxlength="10"
type="text"
placeholder="What is your name?" />
<input type="submit" value="Log In" />
</form>
<a href="https://sm-portpolio.netlify.app">Go to sm-portpolio</a>
<script src="Momentum.js"></script>
</body>
</html>
const loginForm = document.querySelector("#login-form");
const loginInput = document.querySelector("#login-form input");
const linkButton = document.querySelector("a");
function onLoginSubmit(e) {
// console.dir(loginInput);
// console.log("click!!!!!");
// const username = loginInput.value;
e.preventDefault();
console.log(loginInput.value);
}
function clicklinkButton(e) {
console.log(e);
alert("clicked button!!!");
}
loginForm.addEventListener("submit", onLoginSubmit);
linkButton.addEventListener("click", clicklinkButton);
결과: