Jquery add CSS class after 'X' amount of viewport height scrolled
问题 So I have this jQuery function that adds / removes a CSS class to an element after 600px of the viewport height has been scrolled. $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 600) { $(".cta_box").addClass('fadeout'); } else { $(".cta_box").removeClass('fadeout'); } }); I'd like to tweak it so instead of working based off a pixel value, it works off of the view height css measurement "VH", but the equivalent results are what matter in this case. 回答1: It can