<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tree Viewer</title> <style> ul { list-style-type: none; padding-left: 20px; } .toggle { cursor: pointer; color: blue; text-decoration: underline; } </style> </head> <body> <h1>Arborescence des fichiers</h1> <ul id="fileTree"> <li> <span class="toggle">fichier1</span> <ul> <li>fichier2</li> <li>fichier3</li> </ul> </li> <li> <span class="toggle">toto1</span> <ul> <li>toto2</li> <li>toto3</li> <li>toto4</li> </ul> </li> </ul> <script> document.querySelectorAll('.toggle').forEach(item => { item.addEventListener('click', event => { const nextUl = item.nextElementSibling; if (nextUl) { nextUl.style.display = nextUl.style.display === 'none' || nextUl.style.display === '' ? 'block' : 'none'; } }); }); // Initial state: hide all nested lists document.querySelectorAll('#fileTree ul').forEach(ul => { ul.style.display = 'none'; }); </script> </body> </html>