<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www./1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>mouseover和mouseout创建动态按钮</title> <script type="text/javascript"> //通过索引的方法找到想要的元素 /*function mover(){ document.images[0].src='1.gif' } function mout(){ document.images[0].src='2.gif'}*/ //通过name的方法找到想要的元素 /*function mover(){ document.img.src='1.gif' } function mout(){ document.img.src='2.gif'} */ //通过id的方法找到想要的元素
var img=document.getElementById('tu')
function mover(){ document.tu.src='1.gif' } function mout(){ document.tu.src='2.gif'}
</script> </head>
<body> <img src="1.gif" name="img" id="tu"alt="taosheng" onmouseover="mover()" onmouseout="mout()"/>
</body> </html>
|