效果如下所示:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>js教程:鼠标悬停文字上显示图片</title>
<script language="javascript">
function showpic(surl){
var x,y;
x = event.clientx;
y = event.clienty;
document.getelementbyid("layer1").style.left = x;
document.getelementbyid("layer1").style.top = y;
document.getelementbyid("layer1").innerhtml = "<img src=/"" + surl + "/">";
document.getelementbyid("layer1").style.display = "block";
}
function hiddenpic(){
document.getelementbyid("layer1").innerhtml = "";
document.getelementbyid("layer1").style.display = "none";
}
</script>
</head>
<body>
<div id="layer1" style="display:none;position:absolute;z-index:1;"></div>
<img src="/images/logo.gif" onmouseout="hiddenpic();" onmousemove="showpic(this.src);" />
<p></p>
</body>
</html>
新闻热点
疑难解答