I'm trying to trigger the scroll event through jQuery and JavaScript for a wordpress site that I'm developing.
$(window).scroll(function() {
var hT = $('#target').offset().top;
hH = $('#target').outerHeight();
wH = $(window).height();
wS = $(this).scrollTop();
console.log((hT-wH) , wS);
if (wS > (hT+hH-wH)){
console.log('working');
}
});
And nothing happens on the console. The following code doesn't work:
$(window).scroll(function() {
console.log('scrolling');
});
Neither do this:
function scrollFunction() {
console.log('scrolling');
}
window.onscroll = scrollFunction;
I've tested these lines on other non wordpress projects, even in codepen and they work. What I'm missing?
I'm using jQuery 12.2.2. Also, in the same project and for the same purpose, I couldn't make work Waypoints.js, as I posted in this other question.
Any help is really appreciated, thanks!
$(document).ready(function() {});$(document).ready(function() {});that do work fine. I don't think it's cache, as I'm developing on local and with cache disabled on the browser. I tried @zozo idea, to paste second script on console and it returns a window object but doesn't log anything on the console. I don't know what's going on! I don't know much about wordpress, could be something on that? Thanks!