jQuery Problem ! Cannot read property ‘top’ of undefined
-
After update to new version i have this error on checkout and also if i try to go to the shopping cart, or if i try to empty the shopping cart.
Uncaught TypeError: Cannot read property 'top' of undefined at HTMLDocument.<anonymous> (rp-frontend.js?ver=2.7.1:97) at i (jquery.js?ver=1.12.4-wp:2)
This is the code of Restropress where the error is:
jQuery( function($) { // Sticky category menu on mobile var initTopPosition= $('.sticky-sidebar').offset().top; $(window).scroll(function(){ if($(window).scrollTop() > initTopPosition) $('.sticky-sidebar').addClass('mobile-sticky'); else $('.sticky-sidebar').removeClass('mobile-sticky'); });
So, i think it would first check if the jQuery object contains any element before it trys to get its offset:
var TopPosition = $('.sticky-sidebar'); if (TopPosition.length) { var initTopPosition = TopPosition.offset().top; }
Do you agree with me ?
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘jQuery Problem ! Cannot read property ‘top’ of undefined’ is closed to new replies.