const checkBox = document.createElement("input");
checkBox.setAttribute("class", "checkbox");
checkBox.setAttribute("type", "checkbox");
checkBox.addEventListener("change", (e) => {
if (checkBox.checked) {
item.style.textDecoration = "line-through";
item.style.textDecorationThickness = "2px";
item.style.textDecorationColor = "#49c628";
console.log(e)
} else {
item.style.textDecoration = "none";
}
});
type이 checkbox인 input을 setAttribute 메소드를 이용해서 만든다.
addEventListener 중 변화를 감지하는 “change” event를 사용하고,
checkBox의 체크가 되었는지 아닌지를 true/false로 반환하는 checked 속성을 활용한다.

→ 현재 체크 되어 있는 input checkbox의 event를 출력해보면 Event - target - checked : true 인 것을 볼 수 있다.
checked의 속성을 활용하여 style 적용을 하면 된다.