javascript, jquery

마우스 따라다니는 메뉴

디츠 2015. 10. 1. 20:06
<style type="text/css">
	#scroll {position:fixed; width:60px; height:20px; right:50px; bottom:50px; display:none; } 
</style>

<script>
$(document).scroll(function() {
	var top = $("#scroll");
	var position = $(window).scrollTop();
  	var height = $(document).height();
	var bottom = height - position;
    
	if(bottom < 1500) {
		top.fadeOut(500);
	} else if(position > 250) {
		top.fadeIn(500);
	} else if(position < 250) {
		top.fadeOut(500);
	}
 });

$("#scroll").click(function() {
	$("html,body").animate({ scrollTop: 0 }, 500);
});
</script>

<span id="scroll">처음으로</span>