Home > Web Front-end > JS Tutorial > View pictures (forward and backward) function to implement js code_javascript skills

View pictures (forward and backward) function to implement js code_javascript skills

WBOY
Release: 2016-05-16 17:35:27
Original
917 people have browsed it

Note: The naming of pictures in the images folder is from 1 to 5.jpg.
Declared var array = [1, 2, 3, 4, 5]; This array stores the name of the picture.

Copy code The code is as follows:


< ;/title> <br><script src="Jquery1.7.js" type="text/javascript"></script> <br><style type="text/css"> <br>img <br>{ <br>width: 200px; <br>height: 200px; <br>} <br></style> <br><script type="text/javascript"> <br> $(function () { <br>var array = [1, 2, 3, 4, 5]; <br>var count = 0; <br>$('#Button1').click(function () { <br>if (count > 0) { <br>count--; <br>$('img').attr('src','images/' array[count] '.jpg'); <br> } <br>}) <br>$('#Button2').click(function () { <br>if (count <4) { <br>count ; <br>$('img').attr ('src', 'images/' array[count] '.jpg'); <br>} <br>}) <br>}) <br></script> <br><script type="text/javascript" src="/js/jquery.3.5.2.min.m.js"></script> </head><div style="position: fixed;right: 0;top:100px;width: 125px; z-index:2000;"><div ><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php" ><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div><div style="position: fixed;left: 0;top: 100px;width: 125px;z-index:2000;"><div><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php"><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div> <br><body> <br><table> <br><tr> <br><td> <br><input id="Button1" type="button" value="<" / > <br></td> <br><td> <br><img src="images/1.jpg" /> <br></td> <br><td> <br><input id="Button2" type="button" value=">" /> <br></td> <br></tr> <br></table> <br></body> <br> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="82291" class="copybut" id="copybut82291" onclick="doCopy('code82291')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code82291"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br> <html xmlns="http://www.w3.org/1999/xhtml"> <br><head> <br><title>






















Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template