W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript"> myImages=new Array() myImages[0]="/i/eg_mouse.jpg" myImages[1]="/i/eg_smile.gif" myImages[2]="/i/eg_landscape.jpg" myImages[3]="/i/eg_landscape2.jpg" myImages[4]="/i/eg_landscape3.jpg" myImages[5]="/i/eg_greanfoliage.jpg" imagecounter=myImages.length-1 i=0 function first() { document.getElementById('imageviewer').src=myImages[0] i=0 } function previous() { if (i>0) { i-- document.getElementById('imageviewer').src=myImages[i] } } function next() { if (i<imagecounter) { i++ document.getElementById('imageviewer').src=myImages[i] } } function last() { document.getElementById('imageviewer').src=myImages[imagecounter] i=imagecounter } </script> </head> <body> <center> <form> <input type="button" value="First" onclick="first()"> <input type="button" value="Previous" onclick="previous()"> <input type="button" value="Next" onclick="next()"> <input type="button" value="Last" onclick="last()"> </form> <img id="imageviewer" src="/i/eg_mouse.jpg" /> </center> </body> </html>