Prevent Default Behaviour of Hashed Anchor Tag with jQuery

Way back in the day, I use to always set up my event triggering anchor tags a certain way to prevent their default behaviour of having to click-through to a URL or named anchor:
Trigger
Usually, a more simple approach was to use a simple hash:
Trigger
That’s the way I should’ve been doing it, but I really hated how it always made the browser window jump to the top. Solving that wasn’t too complicated. It just took a bit of jQuery.

With that code in place, the browser no longer jumps to the top when using a hashed anchor tag.
Search

Popular Posts

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.