I can’t seem to get a button to smooth scroll to a link on the same page. It worked before but its not working now. I tried pasting the following code but i’m getting all kinds of errors. It just skips instead of sliding… how can i fix this?
1 Expected an identifier and instead saw ‘<‘.
1 Expected an assignment or function call and instead saw an expression.
1 Missing semicolon.
27 Expected an assignment or function call and instead saw an expression.
28 Unclosed regular expression.
28 Unrecoverable syntax error. (100% scanned).
<script>
jQuery(‘li.smooth-scroll-link a’).on(‘click’, function(e) {
var linkHref = jQuery(this).attr(‘href’);
if (linkHref.indexOf(‘#’) === 0) {
var spacerHeight = jQuery(linkHref).height(),
headerHeight = 0;
if (jQuery(‘.sticky-header’).length > 0) {
headerHeight = jQuery(‘.sticky-header’).height();
}
if (jQuery(‘#wpadminbar’).length > 0) {
headerHeight = headerHeight + 28;
}
jQuery(‘html, body’).stop().animate({
scrollTop: jQuery(linkHref).offset().top + spacerHeight – headerHeight – 10
}, 1000, ‘easeInOutExpo’);
e.preventDefault();
} else {
return e;
}
});
</script>