1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title></title>
 6 </head>
 7 <body>
 8 <a href="images/1.jpg" id="a1"><img src="images/1-small.jpg" alt="" id="im"/></a>
 9 <script>
10     //通过id获取图片元素,注册点击事件,添加事件处理函数
11     document.getElementById("im").onclick = function () {
12         //将图片路径设置为a标签的href
13         this.src = document.getElementById("a1").href;
14         //return false;
15     };
16 </script>
17 </body>
18 </html>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
相关资源
相似解决方案