<style type="text/css">
img{
border: 0px;
padding:3px;
}
body{
margin:0px;
font-size:12px;
line-height:25px;
}
input{
margin-top: 5px;
}
</style>
<script type="text/javascript">
function change(){
var imgs=document.getElementsByTagName("img");
//imgs[0].setAttribute("src","images/grape.jpg");
/*也可以采用针对HTML文档的特有方法:*/
imgs[0].src="images/grape.jpg";
}
</script>
</head>
<body style="text-align:center;">
<img src="images/fruit.jpg" alt="水果图片" id="fruit" />
<br /><input name="btn" type="button" value="改变图片" onclick="change()" />
</body>