极速小乌龟

导航

jQuery-切换事件2

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <title>切换事件toggle</title>
 5     <script type="text/javascript" 
 6             src="Jscript/jquery-1.8.2.min.js">
 7     </script>
 8     <style type="text/css">
 9            body{font-size:13px} 
10            img{border:solid 1px #ccc;padding:3px}
11    </style>
12     <script type="text/javascript">
13         $(function() {
14             $("img").toggle(function() {
15                 $("img").attr("src", "Images/img05.jpg");
16                 $("img").attr("title", this.src);
17             }, function() {
18                 $("img").attr("src", "Images/img06.jpg");
19                 $("img").attr("title", this.src);
20             }, function() {
21                 $("img").attr("src", "Images/img07.jpg");
22                 $("img").attr("title", this.src);
23             })
24         })
25     </script>
26 </head>
27 <body>
28      <img />
29 </body>
30 </html>

 

posted on 2017-03-21 22:28  极速小乌龟  阅读(121)  评论(0编辑  收藏  举报