鼠標放上顯示字或圖片

<html>
<head>
<script language="javascript" type="text/javascript">
function cursor(str){
var id = document.getElementById("trail");
//id.innerHTML = str; //文字
id.innerHTML = "<img src=2.jpg></img>"; //圖片
id.style.visibility = "visible";
id.style.position = "absolute";
id.style.left = event.clientX+13;
id.style.top = event.clientY;
}

function hidecursor(){
var id = document.getElementById("trail");
id.style.visibility = "hidden";
}
</script>
</head>
<body>
<h1>請把鼠標移動到鏈接上:</h1>
<a href="/index.html" onMouseMove="cursor('W3School.com.cn')" onMouseOut="hidecursor()">W3School.com.cn</a><br>
<a href="http://www.altavista.com" onMouseMove="cursor('AltaVista')" onMouseOut="hidecursor()">AltaVista</a><br>
<a href="http://www.yahoo.com" onMouseMove="cursor('Yahoo')" onMouseOut="hidecursor()">Yahoo!</a><br>
<div id="trail" style="visibility:hidden; border:#E1E1E1 1px solid; padding:3px;">Hello</div>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章