<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<img id="a" src="img/1.gif" >
<button type="button" id="b">11111</button>
<script>
var imgsrc =["img/1.gif", "img/1.gif", "img/3.gif"];//双引号 //全局变量
var index=0;
window.onload=function()
{
element=document.getElementById("b");
element.addEventListener("click", function(){function1();}, false);
};
function function1()
{
index--;
if(index==-1)
index=2;
document.getElementById("a").src=imgsrc[index];
}
</script>
</body>
</html>
web图片切换
最新推荐文章于 2023-08-21 13:55:36 发布