$(function() {
//This is what the JS is looking for to scroll. a link tag with the # id
$('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({
//this -100 is so the element does not over scroll.
scrollTop: target.offset().top - 100
//this will determine the speed. for example this is take 2 seconds.
}, 2000);
return false;
}
}
});
});
$(".scrollbutton").on("click", function(e) {
e.preventDefault();
console.log("scrolling");
$('html, body').animate({
scrollTop: $(".navigation-bar ").position().top - $(".header-inner").height() + parseInt($("#outer-content-container").css("margin-top"))
}, 2000);
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.