Created
July 23, 2013 02:08
-
-
Save geckotang/6059332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 画面上部にスクロールする | |
* @param selector {String} クリックしてスクロールさせたい要素のセレクタ | |
* @param duration {Number} 移動速度 | |
*/ | |
function smoothScrollTop(selector, duration) { | |
var $topBtn = $(selector), | |
setting_scroll = { | |
duration: duration || 300 | |
}; | |
$topBtn.click(function (e) { | |
e.preventDefault(); | |
$('body,html').stop().animate({ | |
scrollTop: 0 | |
}, setting_scroll.duration); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment