码迷,mamicode.com
首页 > 其他好文 > 详细

jq练习-点击改变图片

时间:2017-09-07 19:33:59      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:分享   charset   title   nbsp   doctype   图片   baidu   body   color   

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title></title>
 6         <style>
 7             td, img {
 8                 width: 100px;
 9                 height: 100px;
10             }
11         </style>
12     </head>
13     <body>
14         <table border="1px" >
15             <tr>
16                 <td><img src="images/1.jpg"/></td>
17                 <td><img src="images/2.jpg"/></td>
18                 <td><img src="images/11.jpg"/></td>                
19             </tr>
20         </table>
21         <img id="showImg" src="images/1.jpg"/>
22 
23         <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
24         <script>
25             $(function(){
26                 $("tr img").click(function () {
27                     $("#showImg").attr("src", $(this).attr("src"));
28                     console.log($(this).index("tr img"));
29                 })
30             })
31             
32         </script>
33         
34     </body>
35 </html>

 

技术分享

 

jq练习-点击改变图片

标签:分享   charset   title   nbsp   doctype   图片   baidu   body   color   

原文地址:http://www.cnblogs.com/1032473245jing/p/7491073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!