JS 手机精简幻灯片
程序员文章站
2022-03-28 17:05:52
...
var curIndex = 0; var timeInterval = 4000; var arr = new Array(); arr[0] = "fukeb.jpg"; arr[1] = "baopi.jpg"; arr[2] = "renliub.jpg"; setInterval(changeImg, timeInterval); function changeImg() { var obj = document.getElementById("showpic"); if (curIndex == arr.length - 1) { curIndex = 0; } else { curIndex += 1; } obj.src = "/templets/v1/images/" + arr[curIndex]; } document.writeln("<div style=\"width:300px;margin:10px auto 0 auto;overflow:hidden;\"><a href=\"/zixun/?f=top_ad\" target=\"_blank\"><img src=\"/templets/v1/images/fukeb.jpg\" id=\"showpic\" /></a></div>");
效果图: