jquery - scroll to anchor not working on Wordpress page -
from this answer, found code animate scroll anchors here.
the site in question wordpress, replaced $
jquery
:
jquery(document).ready(function() { jquery('a[href^="#"]').on('click', function(event) { var target = $(this.href); if( target.length ) { event.preventdefault(); jquery('window').animate({ scrolltop: target.offset().top }, 1000); } } });
edited wolff.
however, clicking anchors @ top of content on this page not scroll movement anchor, still moves instantly on click.
e.g. links don't scroll anchors:
- personal assistants
- after sales service etc.
assistance appreciated.
this work!
jquery('a[href^="#"]').on('click', function(event) { event.preventdefault(); var anch = this.href.match(/#[a-za-z0-9-_]+/i), target = jquery(anch[0]); if( target.length ) { jquery('html, body').animate({ scrolltop: target.offset().top }, 1000); } });
Comments
Post a Comment