JavaScript代码,鼠标放上去显示一张图片
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>First C</title>
</head>
<body>
<h1 >hello world</h1>
<input type="button" value="clickme" onclick="btnclick();"/>
<ul>
<li><a href=".\1.gif"/ onmouseenter="show(this);return false ; " alt="显示图片1.gif">1.gif</li>
<li><a href=".\2.gif"/ onmouseenter="show(this);return false ; " alt="显示图片2.gif">2.gif</li>
</ul>
<img id = "pic" src="" alt ="hell"/>
<div id="msg"></div>
</body>
<%@ language="JScript" %>
<html>
<script>
function show(o) {
var s = o.getAttribute("href");
var p = document.getElementById("pic") ;
p.setAttribute("src",s);
document.getElementById("msg").innerText ="图片说明:" + o.getAttribute("alt");
}
function btnclick() {
var p = document.createElement("h2") ;
var txt = document.createTextNode("new element!11");
p.appendChild(txt);
document.body.appendChild(p);
}
</script>
</html>