onMouseOver 初始值怎么设?说的不太清楚,大家能看懂吗?

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:31:31
要做一个鼠标移上去变换图片,离开时恢复原来的图片的样式,这样写的,效果是达到了,可是每次刷新这个页面时那块区域都是空白的,用鼠标触发一次事件后就没事了,这个怎么解决呢?

<title>无标题文档</title>
<style type="text/css">
.style1 { background:url(images/ind_06.gif) no-repeat;}
.style2 { background:url(images/mouse_06.gif) no-repeat;}
</style>
</head>

<body>
<a href="#"><div onMouseOver="this.className='style1'" onMouseOut="this.className='style2'" style=" width:402px; height:48px;"></div></a>

</body>
</html>

<a href="#"><div onMouseOver="this.className='style1'" onMouseOut="this.className='style2'" style=" width:402px; height:48px;background:url(images/mouse_06.gif) no-repeat;"></div></a>
这样可以吗?

楼上说的办法不行,我也这样加了,可是加上去之后就没有鼠标移上去图片变换的效果了