I am trying to toggle each item on a list to change its style through CSS, but I keep getting an error. Can someone explain what is wrong with my code?
HTML
<button id="enter">Enter</button>
<ul>
<li>Notebook</li>
<li>Apple</li>
<li>Mango</li>
<li>Banana</li>
<li>BlackBerry</li>
<li>Watermelon</li>
</ul>
CSS
.change {
text-decoration: line-through;
}
Javascript
var li = document.querySelectorAll("li");
li.addEventListener("click" , function () {
li.classList.toggle(".change");
})
Uncaught TypeError: li.addEventListener is not a function