Get the scroll position in WordPress Elementor

  elementor, javascript, wordpress

Problem: I need to get the scroll position of the page.

I need get the scroll position. I ran the below code in normal html offline to test my project and it worked, but when I brought it over to wordpress, the scrolling code stopped working. I’m assuming Elementor has something overriding the code below.

var scrollpercent = document.body.scrollTop / document.documentElement.scrollHeight;

Source: Ask Javascript Questions