I have written the below function
function test(use) {
var x = jQuery(window).scrollTop();
var y = x + jQuery(window).height();
console.log(typeof(jQuery(use)));
console.log(typeof(jQuery(use).offset()));
var z = jQuery(use).offset().top;
return ((y > z) && (z >= x - 100));
}
Now the issue is whenever this function is getting called, it gives me an error stating that cannot read property top() of undefined. So, the issue is in variable z. When I used console.log() statements for the 1st statement i.e. console.log(typeof (jQuery(use)));I get the value as object but for 2nd statement i.e. console.log(typeof (jQuery(use).offset()));
I get the value as undefined.
Thanks