js 循环切换图片

 

function changeLot(){
		   var minIndex = 1;
		   var maxIndex = 100;
		   var curIndex = 10;
		   var src = $("ul li img").last().attr("src");
		   var curIndex = src.substring(src.indexOf("_")+1,src.lastIndexOf("."));
		   var html = "";
		   for(var i=1;i<=10;i++){
		       curIndex = parseInt(curIndex)+1;
		       if(curIndex>=maxIndex){
		         curIndex = minIndex;
		       }
		       var filename = "img_"+curIndex+".jpg";
		       html += '<li><a href="javaScript:void(0)"><img src="/images/pics/'+filename+'></a></li>';
		   }
		   $("ul").empty().append(html);
		}

 

注释:图片名称:img_1.jpg ... img_100.jpg  共一百张图片。

posted @ 2017-01-06 20:41  N神3  阅读(1330)  评论(0编辑  收藏  举报