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

257
Views
Cómo forzar el reinicio de una función javascript

Hola, tengo un script que me cambia los colores del texto en intervalos, hay:

 <script> const txts=document.querySelector(".animate-text").children, txtsLen=txts.length; let index=0; const textInTimer=3500, textOutTimer=3300; function animateText() { for(let i=0; i<txtsLen; i++){ txts[i].classList.remove("text-in","text-out"); } txts[index].classList.add("text-in"); setTimeout(function(){ },textOutTimer) setTimeout(function(){ },textInTimer); } window.onload=animateText; </script> <script> var i = 0; function changeClass(){ setTimeout(function() { txts[index].classList.add("text-out"); if(index == txtsLen-1){ index=0; } else{ index++; } animateText(); $("#animate-button").removeClass("anim" + i) i = (i==4)?1:i+1; $("#animate-button").addClass("anim" + (i)); }, 300) } setInterval(changeClass, 3500); windows.onload=changeClass; </script>

Necesito saber cómo puedo obligar a comenzar de nuevo este script después de volver a mi página.

Entonces, el siguiente script para reiniciar se ve:

 <script> document.addEventListener("visibilitychange", function() { if (document.hidden){ console.log("Browser tab is hidden") } else { console.log("Browser tab is visible") //Resetowanie slidera jQuery('#carouselExampleControls').carousel(0); console.log('Slider został przywrócony do 1 slajdu'); // start over changeClass function here console.log('Funkcja changeClass zaczęła działać od początku'); } }); </script>

Necesito comenzar de nuevo con la función changeClass() y ponerla debajo del comentario en el último 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!