该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这是一个图片左右滚动的代码
123$(document).ready(function(){
var totalLiNum=$(*#slide ul*).children(*li*).length;
var trueWidth=totalLiNum*1010;
for(var i=1;i<=totalLiNum;i++){
$(*.icon*).append(*
*);}
$toLeft=function(){
var currentLeft=parseInt($(*#slide ul*).css(*left*).replace(*px*,**));
currentLeft=currentLeft-1010;
$(*#errorinfo*).text(currentLeft);
if((Math.abs(currentLeft))>=(trueWidth-1000)){
$(*#slide ul*).animate({left:0},1000);
}else{
$(*#slide ul*).animate({left:currentLeft},1000);
}
}
$(".toleft").click($toLeft);
$toRight=function(){
var currentLeft=parseInt($(*#slide ul*).css(*left*).replace(*px*,**));
currentLeft=currentLeft+1010;
$(*#errorinfo*).text(currentLeft +"++++"+trueWidth);
if(Math.abs(currentLeft)>=(trueWidth-1000)){
$(*#slide ul*).animate({left:currentLeft},1000);
}else{
$(*#slide ul*).animate({left:0},1000);
}
}
$(".toright").click($toRight);
$selectPic=function(){
var toLeft=$(this).attr(*index*)*1010-1010;
toLeft=toLeft*(-1);
$(*#slide ul*).animate({left:(toLeft+"px")},1000);
$(this).parent().find(*img*).attr(*src*,*images/s_off.png*);
$(this).find(*img*).attr(*src*,*images/s_on.png*);
}
$(".icon li").click($selectPic);
});
.warp{width:1000px;margin:0 auto;border: 1px solid #ccc;}
#slide{width:1000px;border:2px solid #ccc;margin:0 auto;overflow:hidden;}
#slide ul{list-style:none;width:9000px;position:relative;left:0px;margin:0;padding:0;}
#slide ul li{float:left;}
#slide ul li img{margin:30px;width:1000px;}
/*按钮*/
.btn-action{ position:relative;width:35px;height:50px;top: -130px; cursor: pointer;opacity:0.5;}
.btn-action:hover{opacity:1; }
.btn-action span{ text-indent: -99999px;display: block;}
.toleft{left:0; background:url(images/left.png);float: left;}
.toright{right:0;background:url(images/right.png);float: right;}
ul.icon{list-style:none;float:left;display:block;}
ul.icon li {width:32px;float:left;}