<!doctype html>
<html>
<meta http-equiv="content-type" content="text/html" charset="utf-8"/ >
<meta name="keyword" content="图片"/>
<meta name="description" content="javascript图片库"/>
<head>
<title>Images Gallery</title>
</head>
<body>
<h1>Snapshots</h1>
<ul>
<li><a href="images/A1.jpg" title="A fireworks display" target="_self">Fireworks</a></li>
<li><a href="images/A2.jpg" title="A cup of black coffee">Coffee</a></li>
<li><a href="images/A3.jpg" title="A red, red rose">Rose</a></li>
<li><a href="images/A4.jpg" title="The famous clock">Big Ben</a></li>
</ul>
<img src="images/A5.jpg" id="placeholder" alt="my image gallery" border="1px" heigth="200"/>
</body>
<script type="text/javascript">
function showPic(whichpic)
whichpic.getAttribute("href");
var source=whichpic.getAttribute("href");
document.getElementById("placeholder")
//var placeholder = document.getElementById("placeholder");
document.getElementById("placeholder").setAttribute("src",source);
</script>
</html>
你这个代码格式是错的
你这代码没法看啊,能不能贴出一张格式化的代码
那个是你的占位图 是A5.JPG? 想换成哪个图片
ReferenceError: whichpic is not defined 这不是报错提示吗 whichpic 从哪出来的?
js中的代码有问题,改成这个,且把script标签放在body结束下面,html顺序加载的原因,加载script时,找不到这个ID对象,就执行不了
var source=whichpic.getAttribute("href");
document.getElementById("placeholder").setAttribute("src",source);
您a的链接是有问题的,不应该直接链接到图片的
好多问题啊你的代码, function的花括号不打就不说了 图片点击事件好像也没写 whichpic更本就没定义或者没引入js包····