<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function ChangImg(){
//获得IMG的ID="a"对象
var aa = document.getElementById("a");
//更改图片路径
aa.src = "2.jpg";
}
function OverChang(){
var bb = document.getElementById("b");
bb.src = "3.jpg";
//对bb的鼠标滑出事件定义一个方法
bb.onmouseout = function(){
bb.src = "2.jpg";
}
}
</script>
<style type="text/css">
#a{
width:500px;
height:600px;
}
#b{
width:500px;
height:600px;
}
</style>
</head>
<body>
<img id = "a" src = "1.jpg"/>
<!-- 当点击超链接时触发javascript -->
<a href = "javascript:ChangImg()">点我</a>
<!-- 当鼠标滑到ING上时触发javascript -->
<img id = "b" src = "2.jpg" οnmοuseοver="javascript:OverChang()"/>
</body>
</html>