Fork me on GitHub

【jQuery】鼠标接触按钮后改变图片

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 3 <%
 4 String path = request.getContextPath();
 5 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 6 %>
 7 
 8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 9 <html>
10   <head>
11     <base href="<%=basePath%>">
12     
13     <title>My JSP 'jsp2.jsp' starting page</title>
14     
15     <meta http-equiv="pragma" content="no-cache">
16     <meta http-equiv="cache-control" content="no-cache">
17     <meta http-equiv="expires" content="0">    
18     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
19     <meta http-equiv="description" content="This is my page">
20     <!--
21     <link rel="stylesheet" type="text/css" href="styles.css">
22     -->
23 <script type="text/javascript" src="<c:url value='/jquery-1.5.1.js'/>"></script><!-- 标签,需导入c标签库 -->
24 <script type="text/javascript">
25     $(function(){
26         $("#d1").hover(
27             function(){//鼠标进入元素时
28                 $("#d1").text("1");
29             },
30             function(){//鼠标离开元素时
31                 $("#d1").text("2");
32             }
33         )    
34     });
35 
36 </script>
37 <style type="text/css">
38 .xxx{
39     border: 1px solid red;
40     width: 100px;
41     height: 100px;
42 }
43 </style>
44   </head>
45   
46   <body>
47     This is my JSP page. <br>
48     <div id="d1" class="xxx">nihao</div>
49   </body>
50 </html>

 

posted @ 2015-06-15 21:53  郑斌blog  阅读(349)  评论(0编辑  收藏  举报