I have a file structure like
<div id='root'>
<li></li>
<li></li>
<li></li>
<li></li>
</div>
Those <li><li> tags include some content, and I would like to open/close them, but using a pure javascript only. I've tried so using the document.querySelectorAll, for now the code goes something like this
let lis = document.querySelectorAll('#root > li');
function show(e) {
alert('hey');
}
lis[1].addEventListener('click', show(), false);
But it alerts only when I refresh the page, not "listening" to the actual click, and I still don't know how to refer a precise element. Maybe there are some articles I could use?
P.S. I can't modify the HTML code, so I can't use document.getElementById, and jQuery is also not for me at the moment. Thanks a lot in advance.