Can someone please help me with a function to hide a list element, one by one, when clicking on it? I only got it to work but for one single element, I am not sure how it would go for all of them.
Suppose I have a list of 5 elements. When i click on element 1, it dissapears. If I click on element two, it also dissapears and so on.
I would like it to do on javascript vanilla only
This is that I've tried so far:
<!DOCTYPE html>
<html>
<body>
<ul>
<li id ="id1" onclick="document.getElementById('id1').style.visibility='hidden'">Coffee</li>
<li class ="id1" onclick="document.getElementById('id1').style.visibility='hidden'">Coffee 2</li>
<li class ="id1" onclick="document.getElementById('id1').style.visibility='hidden'">Coffee 3</li>
</ul>
</body>
</html>