这是html代码:
<!doctype html>
<html>
<head>
<title>变形金刚</title>
<meta charset="utf-8">
<link type="text/css" rel="stylesheet" href="bxjg.css">
<script type="text/javascript" src="bxjg.js"></script>
</head>
<body>
<h1>变形金刚图赏</h1>
<ul id="tupianku">
<li>
<a href="images/bxjg1.jpg" title="变形金刚1">变形金刚1</a>
</li>
<li>
<a href="images/bxjg2.jpg" title="变形金刚2">变形金刚2</a>
</li>
<li>
<a href="images/bxjg3.jpg" title="变形金刚3">变形金刚3</a>
</li>
</ul>
<img id="placeholder" src="images/bxjg.jpg" alt="变形金刚" width="293" height="220">
<p id="description">
变形金刚
</p>
</body>
</html>这是js代码:(为了练习没有用变量)window.onload=gaibian;function gaibian(){ for(var i=0;i<document.getElementById("tupianku").getElementsTagName("a").length;i++){ document.getElementById("tupianku").getElementsByTagName("a")[i].onclick=function(){ bianhuan(this); return false; } }}function bianhuan(tupian){ document.getElementById("placeholder").setAttribute("src",tupian.getAttribute("href"));}
添加回答
举报
0/150
提交
取消