源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

基于jQuery实现图片的前进与后退功能

  • 时间:2020-07-13 03:25 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:基于jQuery实现图片的前进与后退功能
[u]复制代码[/u] 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> #mydiv{ position:absolute; width:500px; height:400px; top:50%; left:50%; margin-top:-200px; margin-left:-290px; } img{ width:480px; height:380px;} </style> <script src="jquery-1.9.1.js" type="text/javascript"></script> <script src="Jquery1.7.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var array = [1, 2, 3, 4, 5, 6]; var count = 0; //后退 $('#Button1').click(function () { if (count > 0) { count--; $('img').attr('src', 'images/' + array[count] + '.jpg'); } }) //前进 $('#Button2').click(function () { if (count < 5) { count++; $('img').attr('src', 'images/' + array[count] + '.jpg'); } }) }) </script> </head> <body> <div id="mydiv"> <table><tr><td><input id="Button1" type="button" value="<" /></td><td><img src="images/1.jpg" /></td><td><input id="Button2" type="button" value=">" /></td></tr></table> </div> </body> </html>
效果如下: [img]http://files.jb51.net/file_images/article/201304/20130424160448.jpg?201332416515[/img]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部