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

159
Views
No se puede obtener la variable con la selección de consulta

He escrito una pequeña función JS para cambiar el nombre de clase de un elemento HTML. Lamentablemente, mi const de alguna manera no está definida, por lo que la función no se ejecuta.

Este es mi JS:

 deglitcher(); function deglitcher() { const glitch = document.querySelector('#bottom-gl'); setTimeout(function () { glitch.className = 'glitch-off'; }, 2000); }

Así es como se ve mi HTML:

 <div class="sign"> <h1 class="glitch" id="upper-gl" data-text="Glitch1">Glitch1</h1> &nbsp; <h1 class="glitch" id="bottom-gl"data-text="Glitch2">Glitch2</h1> <span class="sub">Test</span> </div>

Me gustaría que se viera así:

 <div class="sign"> <h1 class="glitch-off" id="upper-gl" data-text="Glitch1">Glitch1</h1> &nbsp; <h1 class="glitch-off" id="bottom-gl"data-text="Glitch2">Glitch2</h1> <span class="sub">Test</span> </div>

Espero que alguien más inteligente que yo pueda resolverlo.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La solución que se me ocurrió, gracias a la generosa ayuda de ARMAAN y A Haworth , es la siguiente:

  1. Corrija el código para el selector incorrecto ('bottom-gl) en lugar de ('#bottom-gl')
  2. Utilice classList en lugar de className
 deglitcher(); function deglitcher() { const glitch = document.getElementById('bottom-gl'); setTimeout(function () { console.log(glitch) glitch.classList.add('glitch-off'); glitch.classList.remove('glitch'); console.log('Trele Morele'); }, 2000); }
  1. Y finalmente, gracias a A Haworth , usé defer en mi cargador:
 <script src="../src/js/glitch.js" defer></script>

A partir de ahora, el problema está resuelto, gracias por su ayuda a todos ;-)

about 4 years ago · Juan Pablo Isaza Report
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!