Skip to content

Commit

Permalink
노마드(4.1~4.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
syj318 committed Aug 20, 2024
1 parent cf49f04 commit 1a1f6b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
20 changes: 12 additions & 8 deletions yoojin/노마드/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const loginForm = document.querySelector("#login-form ");
const loginInput = document.querySelector("#login-form input");
const loginButton = document.querySelector("#login-form button");
const greeting = document.querySelector("#greeting");

function onLoginBtnClick() {
console.log("hello", loginInput.value);
}
const HIDDEN_CLASSNAME = "hidden";

if (loginButton) {
loginButton.addEventListener("click", onLoginBtnClick);
} else {
console.error("loginButton이 존재하지 않습니다.");
function onLoginSubmit(event) {
event.preventDefault();
loginForm.classList.add(HIDDEN_CLASSNAME);
const username = loginInput.value;
localStorage.setItem("username", username);
greeting.innerText = "Hello" + username;
greeting.classList.remove(HIDDEN_CLASSNAME);
}

loginForm.addEventListener("submit", onLoginSubmit);
6 changes: 2 additions & 4 deletions yoojin/노마드/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
<title>Momentum App</title>
</head>
<body>
<div id="login-form">
<input type="text" placeholder="What is your name?" />
<button>Log In</button>
</div>
<form id="login-form"></form>
<h1 id="greeting" class="hidden"></h1>
<script src="app.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions yoojin/노마드/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.hidden {
display: none;
}

0 comments on commit 1a1f6b6

Please sign in to comment.