代码是这样的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<style>
*{ margin:0; padding:0; list-style:none}
body{ font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:1.8;}
img{ display:block; border:0;}
h1,h2{ background:#FFF; line-height:2.5; font-size:14px; padding-left:10px; color:#fff;}
#pics{
border-left: 3px solid #468C50;
border-right: 3px solid #468C50;
background: #fff;
float: left;
width: 950px;
}
li{ float:left;}
a{ display:block; background:#fff; border:1px solid #A4D742; text-align:center; color:#598628; text-decoration:none; padding:5px; margin:10px;}
a:hover,a:active{ background:#99CC33; border:1px solid #85B829; border-left:1px solid #fff; border-top:1px solid #fff; color:#fff}
#showpic{ border:1px solid #85B829; padding:5px; display:none; clear:left; background:#FFF; text-align: center}
ul,#showpic{ margin:10px;}
h2{ color:#598628; background:none; text-align:left}
#showpic img{ margin:auto}
</style>
</head>
<body>
<div id="pics">
<ul>
<li><a href="trend-04.png"><img src="trend-04.png" height="130" /></a></li>
</ul>
</div>
<script language="javascript">
function setDiv(){
var pics = document.getElementById("pics");
var showpic = document.createElement("div");
showpic.setAttribute("id", "showpic");
pics.appendChild(showpic);
showpic.appendChild(document.createElement("h2"));
showpic.appendChild(document.createElement("img"));
var links = pics.getElementsByTagName("a");
for(var k=0; k<links.length; k++){
links[k].onclick = function(){
return showPic(this);
}
}
}
function showPic(pic){
var showpic = document.getElementById("showpic");
showpic.style.display = "block";
showpic.getElementsByTagName("h2")[0].innerHTML = pic.title;
showpic.getElementsByTagName("img")[0].setAttribute("src", pic.href);
return false;
}
window.onload = setDiv;
</script>
</body>
</html>