Skip to content

Instantly share code, notes, and snippets.

@uhfx uhfx/up.html
Created Jul 13, 2014

Embed
What would you like to do?
上に戻るボタンのhtmlソース http://ozpa-h4.com/2012/05/09/jquery_back_to_top_button/
<!-- 「トップへ戻る」ボタン -->
<div id="back-to-top" style="position:fixed;right:12px;bottom:12px"><a href="#"><img src="画像のURLを用意" /></a></div>
<script>
$(function(){
$("#back-to-top").hide();
$(window).scroll(function(){
if($(this).scrollTop() > 500){
$("#back-to-top").fadeIn();
} else{
$("#back-to-top").fadeOut();
}
});
$("#back-to-top a").click(function(){
$("body,html").animate({
scrollTop:0
},700);
return false;
});
});
</script>
<!-- 「トップへ戻る」ボタン ここまで -->
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.