var scrollWrapW,myScroll;
var rollDirection = 0; //0为左 1为右
var speed = 500;
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
function __scrollBox()
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (rollDirection == 0)
{
scrollWrapW = -($('ul li').eq(0).outerWidth(true) + $('ul li').eq(1).outerWidth(true)) + 'px';
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$('ul').animate(
{left:scrollWrapW},
{
duration:200,
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
complete:function()
{
$('ul').append($('ul li:first')).append($('ul li:first'));
$('ul').css("left","0");
}
});
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
}else
{
var last = $('ul li').length - 1;
var last2 = $('ul li').length - 2;
scrollWrapW = -($('ul li').eq(last).outerWidth(true) + $('ul li').eq(last2).outerWidth(true)) + 'px';
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$('ul').animate(
{left:0},
{
duration:200,
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
complete:function()
{
$('ul').prepend($('ul li:last')).prepend($('ul li:last'));
$('ul').css("left",scrollWrapW);
}
});
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
$(document).ready(function()
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//* roll control */
myScroll = setInterval(__scrollBox,speed);
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$('#scrool_wrap').hover(function()
{
clearInterval(myScroll);
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
},function()
{
myScroll = setInterval(__scrollBox,speed);
});
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//* left control */
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$('.left').click(function()
{
rollDirection = 0;
});
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$('.right').click(function()
{
rollDirection = 1;
});
})
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
* {
}{
margin:0;
padding:0;
border:0;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
div {
}{
width:368px;
overflow:hidden;
position:relative;
height:109px;
margin:0 auto;
background:#F00;
border:5px solid #F00;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
ul {
}{
height:109px;
position:absolute;
width:1000px;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
li {
}{
float:left;
position:relative;
margin-right:5px;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
span {
}{
cursor:pointer;
}
<span class="left">向左移动</span> <span class="right">向右边移动</span> <br />
<br />
<br />
<br />
<br />
<br />
<br />
<div>
<ul id="scrool_wrap">
<li><a href="#" target="_blank"><img src="img/01.jpg" width="184" height="109" /></a></li>
<li><a href="#" target="_blank"><img src="img/02.jpg" width="184" height="109" /></a></li>
<li><a href="#" target="_blank"><img src="img/03.jpg" width="184" height="109" /></a></li>
<li><a href="#" target="_blank"><img src="img/04.jpg" width="184" height="109" /></a></li>
</ul>
</div>
posted @
2009-07-27 15:53
朝夕
阅读(
912)
评论()
编辑
收藏
举报