If u r building website with jQuery, it’s common if the browser auto scroll to top when user click on anchor element. This happen to me many times and i always forget how to disable the auto scrolling. Thus this post is being created for my own reference and for other developer 🙂
To disable autoscrolling to top when user click on anchor element, follow the steps below:
Advertisements
- In the same page, copy and paste this script within your script tag
$(document).ready(function() { $('body').on('click', '[href^=#]', function (e) { e.preventDefault() }); });
- Now refresh you page and you may try to click on anchor element and the autoscrolling should be stop by now
Happy coding!
Related posts:
How to svn thru ssh in Linux / Mac
How to hide apache2 version number in error page
Mod Security - Open source Web Application Firewall
Free Project Management software for Mac OS X - GanttProject
How to re-arrange account order in Thunderbird
Prestashop 1.6: "Unexpected token <" error when upload category thumbnail
MySQL 5.5 PDO::__construct(): The server requested authentication method unknown to the client [mysq...
How to flush DNS cache in Linux / Windows / Mac
Share this with your friends:-