- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=gbk" />
- <title>Image Gallery</title>
- <script type="text/javascript" >
- function showPic(whichpic) {
- var source = whichpic.getAttribute("href"); //获取当前点击的元素的属性href的值
- var placeholder = document.getElementById("placeholder"); //获取目标
- placeholder.setAttribute("src",source);
- /*
- 设置目标的属性src。从而达到改变图片。
js小实例(点击链接改变图片)
最新推荐文章于 2022-10-07 00:22:36 发布