1
<ul>
<li onclick="mostrar('img')">
PASTA - Fotos
<ul>
<li id="img" style="display: none;">Imagem1.jpg</li>
<li id="img2" style="display: block;"> Imagem2.jpg </li>
</ul>
</li><br>
<li> PASTA - BOLETOS
<ul>
<li id="boleto">boleto.pdf</li>
</ul>
</li>
</ul>
<script>
function mostrar(){
let show = document.getElementById('img')
if(show.style.display == 'none'){
show.style.display = 'block'
}
else{
show.style.display = 'none'
}
}
</script>
I am studying and decided to test the logic of a common Folder of a computer.
1º Click on the folder and expand (show) your files.
My question is: How to do this for "Imagem2.jpg" without creating another function? I want to keep the same function.
Note: I want the help in pure Javascript, do not cite Jquery, because I’m not studying it yet.