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

156
Views
Hacer que el botón desaparezca si el hash cambia durante el desplazamiento

Entonces, estoy usando fullpage.js jquery para desplazarme en mi sitio web.
Cada sección de desplazamiento se divide en hashes, como index.html/#firstPage, etc.
Hice un desplazamiento fijo al botón superior, pero quiero hacerlo desaparecer si el hash es igual a #firstPage.
También hice un script Js, pero no funciona. ¿Algunas ideas?

 mybutton = document.getElementById("scroll_top_button"); var stringHash = window.location.hash; console.log(stringHash); // Returns hash and it works function hashDisappear() { if (stringHash == "#firstPage") {// this thing doesn't work at all. mybutton.style.display = "none"; } else { mybutton.style.display = "block"; } }
Editar
Mi mal, nunca se llamó a la función, pero cuando cambia el hash, debido al desplazamiento, el botón no aparece, solo después de reiniciar la página. ¿Cómo hacer que verifique si el hash cambia y ejecuta la función o algo?

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

0

Intentalo

 window.addEventListener('hashchange', function() { //Your Function }, false);

https://developer.mozilla.org/docs/Web/API/Window/hashchange_event

https://caniuse.com/?search=hashchange

about 4 years ago · Juan Pablo Isaza Report

0

Encontré el guión perfecto para esta situación.

 mybutton = document.getElementById("scroll_top_button"); function locationHashChanged() { if (location.hash === "#firstPage") { mybutton.style.display = "none"; } else { mybutton.style.display = "block"; } } window.onhashchange = locationHashChanged;

Pero @Smith Charl me ayudó a encontrar la lógica principal para hacer este script aunque

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!