JS特效 按钮实现图片左右轮换(总共4张图,img1.jpg,img2.jpg,img3.jpg,img4.jpg)

JavaScript018

JS特效 按钮实现图片左右轮换(总共4张图,img1.jpg,img2.jpg,img3.jpg,img4.jpg),第1张

var picID = 0//换成网页中那幅图在picURL中的序号(记得要从0开始数)

var picURL = ["images/img1.jpg","images/img2.jpg","images/img3.jpg"]//将图片链接地址放进来,数量随意

function showimg(str){

 if(str=="L"){

if(picID==0){

 picID = picURL.length-1

 document.getElementById("advimg").src = picURL[picID]

}else{

 document.getElementById("advimg").src = picURL[--picID]

}

 }else if(str=="R"){

if(picID==(picURL.length-1)){

 picID = 0

 document.getElementById("advimg").src = picURL[picID]

}else{

 document.getElementById("advimg").src = picURL[++picID]

}

 }

}

你都在用jQuery了为什麼要用这麽别扭的方式搞特效?

<div class="SlideWrapper" style="display:none">

<img src="yourImage">

</div>

<script>

jQuery(function($)

{

$('.SlideWrapper').slideDown(4000)

})

<script>