.className
#id
선택자:nth-child(x)
: x번째 요소예시
<div class="list">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<p>안녕</p>
</div>
const a = document.querySelector('.a')
console.log(a) // <div class="a"></div>
const all = document.querySelectorAll('.list')
console.log(all)
/*
NodeList(3)[div.a, div.b, div.c]
*/
console.log(all[0]) // <div class="a"></div>
const list = document.querySelector('.list')
list.setAttribute('data-id',123)
console.log(list.getAttribute('data-id')) // 123
console.log(list.dataset.id) // 123
<div class="list" data-id="123">
...
const pEle = document.createElement('p')
pEle.innerHTML = '안녕'
pEle //<p>안녕</p>
const list = document.querySelector('.list')
list.appendChild(pEle)
<div class="list">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<p>안녕</p>
</div>
const list = document.querySelector('.list')
list.removeChild(document.querySelector('.b'))
<div class="list">
<div class="a"></div>
<div class="c"></div>
<p>안녕</p>
</div>
const list = document.querySelector('.list')
list.classList.add('haha')
<div class="list haha">
const list = document.querySelector('.list')
list.className = 'hoho'
<div class="hoho">
const list = document.querySelector('.list')
list.classList.remove('list')
<div class="haha">
📑 reference