I have a sidebar that scrolls on desktop/iPad view but it also affects it on mobile view I would like to disable this JavaScript code on mobile view/smaller screen.
var length = $('#filters-sidebar-wrap').height() - $('#filters-sidebar').height() + $('#filters-sidebar-wrap').offset().top;
$(window).scroll(function () {
var scroll = $(this).scrollTop();
var height = $('#filters-sidebar').height() + 'px';
if (scroll < $('#filters-sidebar-wrap').offset().top) {
$('#filters-sidebar').css({
'position': 'absolute',
'top': '40px',
'width': '290px'
});
} else if (scroll > length ) {
$('#filters-sidebar').css({
'position': 'absolute',
'bottom': '0',
'top': 'auto',
'width': '290px'
});
} else {
$('#filters-sidebar').css({
'position': 'fixed',
'top': '128px',
'width': '290px',
'height': 'height'
});
}
});
I was able to solve my problem, Thank you for all the help!
if(window.innerWidth < 992 ) {
$("#filters-sidebar").removeAttr("style");
} else {
/// Add code here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.