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"; } }Intentalo
window.addEventListener('hashchange', function() { //Your Function }, false);https://developer.mozilla.org/docs/Web/API/Window/hashchange_event
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