Onscroll not working

  • 4 September 2019
  • 1 reply
  • 2 views

Hi,

I wonder why the below script is not working in Unbounce. Please help!

<script>

// When the user scrolls down 300px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
window.document.getElementById("#lp-pom-button-5067").style.display = “block”;
} else {
window.document.getElementById("#lp-pom-button-5067").style.display = “none”;
}
}

}
</script>


1 reply

Try remove the # from the getElementbyID

Reply