<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>图片转换</h1>
<ul>
<li>
<a href="images/pic1.jpg" onclick="showPic(this);return false">图片1</a>
</li>
<li>
<a href="images/pic2.jpg" onclick="showPic(this);return false">图片2</a>
</li>
<li>
<a href="images/pic3.jpg" onclick="showPic(this);return false">图片3</a>
</li>
<li>
<a href="images/pic4.jpg" onclick="showPic(this);return false">图片4</a>
</li>
</ul>
<img src="images/pic1.jpg"id="placeholder" alt="my image gallery" />
<style type="text/css">
#placeholder{
width: 600px;
height: 400px;
border: 1px solid #fff;
}
</style>
<script>
function showPic(whichpic){
var source=whichpic.getAttribute("href");
var placeholder=document.getElementById("placeholder");
placeholder.setAttribute("src",source);
}
function countBodyChildren() {
var body_element = document.geElementsByTagName("body")[0];
alert (body_element.childNodes.length);
}
window.onload = countBodyChildren;
</script>
</body>
</html>
添加回答
举报
0/150
提交
取消