로그인, 회원가입후 더 많은 혜택을 누리세요 회원가입 닫기
전체 카테고리


왓슈 웹/모바일/SNS 최신 댓글


  • 플러스친구 카카오채널-스토리

scrollTop() scrollTop

2014.01.22 17:01

조회 수:1793






<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>scrollTop demo</title>
<style>
p {
margin: 10px;
padding: 5px;
border: 2px solid #666;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p>Hello</p><p></p>
<script>
var p = $( "p:first" );
$( "p:last" ).text( "scrollTop:" + p.scrollTop() );
</script>
</body>
</html>
--------------------------------
 

Hello

scrollTop:0

 

////////////////////////////////

 

 

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>scrollTop demo</title>
<style>
div.demo {
background: #ccc none repeat scroll 0 0;
border: 3px solid #666;
margin: 5px;
padding: 5px;
position: relative;
width: 200px;
height: 100px;
overflow: auto;
}
p {
margin: 10px;
padding: 5px;
border: 2px solid #666;
width: 1000px;
height: 1000px;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div class="demo"><h1>lalala</h1><p>Hello</p></div>
<script>
$( "div.demo" ).scrollTop( 300 );
</script>
</body>
</html>
 
------------------------------------------
//////////////////////////////////////////