<%@ Page Language="C#" AutoEventWireup="true" CodeFile="图片浏览器.aspx.cs" Inherits="图片浏览器" %>
<!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 runat="server">
<title></title>
<style type="text/css">
img{ width:300px; height:400px;}
a{ position:relative; top:-200px;}
</style>
<script src="Jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var array = new Array('0.jpg', '1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.gif', '6.jpg', '7.jpg', '8.jpg', 'onSuccess.gif');//把图片名存在数组里
var count = 0;
$('img').attr('src', 'images/' + array[count]); //显示第一张图片
$('#go').click(function () {
count++;
if (count >= array.length) { //如果count大于数组的最大下标,则归零,继续循环
count = 0;
}
//无论是否满足上面的if条件,都会执行
$('img').attr('src', 'images/' + array[count]);
})//前进
$('#back').click(function () {
count--;
if (count <= 0) {
count = array.length - 1; //如果count小于数组的最小下标,则跳至数组的最后一张图片,即下标为数组的长度-1,继续循环
}
$('img').attr('src', 'images/' + array[count]);
})//后退
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<span><a href="#" id="back">后退</a></span>
<img/>
<span><a href="#" id="go">前进</a></span>
</div>
</form>
</body>
</html>
<!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 runat="server">
<title></title>
<style type="text/css">
img{ width:300px; height:400px;}
a{ position:relative; top:-200px;}
</style>
<script src="Jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var array = new Array('0.jpg', '1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.gif', '6.jpg', '7.jpg', '8.jpg', 'onSuccess.gif');//把图片名存在数组里
var count = 0;
$('img').attr('src', 'images/' + array[count]); //显示第一张图片
$('#go').click(function () {
count++;
if (count >= array.length) { //如果count大于数组的最大下标,则归零,继续循环
count = 0;
}
//无论是否满足上面的if条件,都会执行
$('img').attr('src', 'images/' + array[count]);
})//前进
$('#back').click(function () {
count--;
if (count <= 0) {
count = array.length - 1; //如果count小于数组的最小下标,则跳至数组的最后一张图片,即下标为数组的长度-1,继续循环
}
$('img').attr('src', 'images/' + array[count]);
})//后退
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<span><a href="#" id="back">后退</a></span>
<img/>
<span><a href="#" id="go">前进</a></span>
</div>
</form>
</body>
</html>