JS写的一个图片轮换特效,每次一张,带左右箭头按钮。
发布网友
发布时间:2022-04-25 10:21
我来回答
共1个回答
热心网友
时间:2022-04-25 11:50
<script>
var picarr=new Array("1.jpg","2.jpg","3.jpg");
var mypoint=-1;
function changepic(myflag)
{
if(myflag<0)
{
mypoint=mypoint-1;
if (mypoint<0) { mypoint=picarr.length-1;}
}
else
{
mypoint=mypoint+1;
if (mypoint==picarr.length) { mypoint=0;}
}
document.getElementById("pic").src=picarr[mypoint];
}
</script>
<body style="text-align:center;" onload="changepic(0);">
<div style="width:810px;background-color:#eee">
<span onclick="changepic(-1);" onmousemove="this.style.color='red';" onmouseout="this.style.color='blue';" style="cursor: hand">《-LastOne </span>
<img id=pic border="0" width=600 style="text-align:center;vertical-align:middle;"/>
<span onclick="changepic(0);" style="cursor: hand;" onmousemove="this.style.color='red';" onmouseout="this.style.color='blue';" > NextOne-》</span>
</div>
<body>