const loginForm = document.getElementById("login-form");
//html에서 login-form(html element)을 찾음
const loninInput = loginForm.querySelector("input");
const loninButton = loginForm.querySelector("button");
<!DOCTYPE html>
<html lang="en">
<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">
<link rel="stylesheet" href="style.css">
<title>Hello from HTML!</title>
</head>
<body>
<div class="login-form">
<input type="text" placeholder="What is your name?" />
<button>Log In</button>
</div>
<script src="app.js"></script>
</body>
</html>
const loninInput = document.querySelector(".login-form input"); //왜 .으로 해야 에러가 안뜨지
const loninButton = document.querySelector(".login-form button");
function LoginButtonClick(){
console.log(loninInput.value); //value값 받아오고 콘솔에 출력
}
loninButton.addEventListener("click",LoginButtonClick);