PDA

View Full Version : دسترسی ب اسکرول دایو



olampiad
سه شنبه 21 مرداد 1393, 21:35 عصر
سلام و خسته نباشید
ب این کد های من ی نگا بندازید
میشه این رو یک بار روی سیستم خودتون اجرا کنید.
میبینید که من ب دایوم اسکرول دادم
میخوام وقتی که ماس روی دکمه ی top یا button رفت اسکرول دایوم ب سمت بالا و پایین حرکت کنه.
حالا خواستم ببینم با چ تابعی ب این اسکرول دسترسی داشته باشم
ممنون بابت راهنمایی ها





<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript">

$(document).ready(function(e) {

$('.tt').draggable({
revert:true
})

$('#two').droppable({

})






});
</script>

<style type="text/css">

#one{
text-align:center;
margin:auto;
width:400px;
overflow:scroll;
height:500px;
background:#FFC;
position:relative;
}



.tt{
float:left;
width:250px;
height:40px;
background:#FC0;
margin:4px;
text-align:center;
}

#top{
width:40px;
height:40px;
background:#000;
opacity:0.3;
position:fixed;
top:50px;
right:550px;
color:#FFF;
}

#button{
width:40px;
height:40px;
background:#000;
opacity:0.3;
position:fixed;
top:400px;
right:550px;
color:#FFF;
}


</style>

</head>
<body>

<div id="one">
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>
<div class="tt">one</div>


<div id="top">
top
</div>


<div id="button">
button
</div>




</div>









</body>
</html>

2undercover
سه شنبه 21 مرداد 1393, 21:47 عصر
با استفاده از متد scrollTop از اون شئ.


$('.div').scrollTop(); // Get the value
$('.div').scrollTop(30); // Set the value