<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>DOM編程藝術(shù)圖片庫</title>
</head>
<body>
<h1>Snapshots</h1>
<ul>
<li><a?href="images/5.jpg"?onclick="showPic(this);?return?false;">china?map</a></li>
<li><a?href="images/2.jpg"?onclick="showPic(this);?return?false;">words</a></li>
<li><a?href="images/3.jpg"?onclick="showPic(this);?return?false;">html</a></li>
<li><a?href="images/4.jpg"?onclick="showPic(this);?return?false;">friends</a></li>
</ul>
<img?id="placeholder"?src="images/1.jpg"?alt="my?image">
<script?src="js/showPic.js"></script>
</body>
</html>function?showPic(whichpic)?{
var?source?=?whichpic.getAttribute("href");
var?placeholder?=?document.getElementById('placeholder');
placeholder.setAttribute("src",source);
}效果能實(shí)現(xiàn),就是這個(gè)函數(shù)傳參有點(diǎn)不太明白,望有人能解答的詳細(xì)的.
DOM編程藝術(shù)中的案例
自由的氣息
2017-04-25 12:39:29