Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
cambiar el tema de un documento usando múltiples archivos de índice

Tengo un total de 5 archivos index.html. Todos tienen diferentes nombres de índice y están vinculados a un archivo JS. Cuando hago clic en el botón para cambiar el tema de la página index.html. El tema cambia a tema claro y se establece en localStorage. Las otras páginas no se modifican. ¿Puede alguien llevarme en la dirección correcta? ¿Qué estoy haciendo mal?

 // Switch theme/add to local storage to all body elements in multiple .html files const bodyElement = document.body // Get the theme button via id const themeToggleBtn = selectElement('#theme-toggle-btn'); // passes the theme button to the toggleTheme function const currentTheme = localStorage.getItem('currentTheme'); // checks if there is a current theme in local storage if (currentTheme) { bodyElement.classList.add('light-theme'); } // event listener btn is clicked the body element changes theme themeToggleBtn.addEventListener('click', () => { bodyElement.classList.toggle('light-theme'); // checks if element has the class and sets it in local storage if (bodyElement.classList.contains('light-theme')) { localStorage.setItem('currentTheme', 'themeActive'); // if not it removes it } else { localStorage.removeItem('currentTheme'); } });
 <script src="./assets/js/main.js"></script>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!