Skip to content
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>이벤트 - TODOS</title>
<link rel="stylesheet" href="./src/css/style.css" />
<script type="module" src="./src/index.js" defer></script>
</head>

<body>
<div class="todoapp">
<div id="app" class="todoapp">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 프론트엔드 공부가 부족해서 그런데, 이런식으로 해서 바닐라 JS만으로도 JS 분리를 깔끔하게 되는 것 같아요.
좋은 경험 얻어 갑니다. 👍

<h1>TODOS</h1>
<input id="new-todo-title" class="new-todo" placeholder="할일을 추가해주세요" autofocus />
<main>
Expand Down
5 changes: 5 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default class App {
constructor($target) {
console.log($target);
}
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import App from './App.js';
import { $ } from './utils/utils.js';

document.addEventListener('DOMContentLoaded', () => new App($('#app')));
4 changes: 4 additions & 0 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const $ = (selector) => document.querySelector(selector);
const $$ = (selector) => document.querySelectorAll(selector);

export { $, $$ };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$를 querySelector를 할당하여 사용하는 것은 보았는데,
$$를 querySelectorAll 이렇게도 사용할 수 있겠구나하고 좋은 팁 얻습니다. ^^