Javascript to jQuery help?
- window.onscroll = function() {
- progress()
- };
- function progress() {
- var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
- var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
- var scrolled = (winScroll / height) * 100;
- document.getElementById("myBar").style.width = scrolled + "%";
- }
I thought something like this might work :
- jQuery(document).ready(function($) {
- $(document).on( 'scroll', function() {
- if ( $(document).scrollTop() * 100 ) {
- $( '#myBar' );
- });