[jquery] 원하는 태그(위치)로 스크롤 이동하기
2017-05-18 14:47:37.0
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {margin-bottom:1000px;}
</style>
<script>
function fnMove(seq){
var offset = $("#div" + seq).offset();
$('html, body').animate({scrollTop : offset.top}, 400);
}
</script>
<body>
<button onclick="fnMove('1')">div1로 이동</button>
<button onclick="fnMove('2')">div2로 이동</button>
<button onclick="fnMove('3')">div3로 이동</button>
<div id="div1">div1</div>
<div id="div2">div2</div>
<div id="div3">div3</div>
</body>
</html>
출처: http://cofs.tistory.com/191
Last Update
2024-05-07 09:17:31.0