I have a jquery issue which I need some help with and can't seem to find any results which solve my issue. I have a 1 page site which uses the jquery below to smoothly scroll to anchor links. The only issue is that when it's on mobile, I need to adjust the scroll to have a top -170px deficit. How do I only target mobile queries using the same function below?
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 700);
return false;
}
}
});
});