通过javascript改变li的背景图片问题,附全部代码
<html>
<head>
<title> css test </title>
<script type= "text/javascript ">
function chang(objThis)
{
objThis.style.backgroundImage= "newsobg.gif ";
}
function nochang(objThis)
{
objThis.style.backgroundImage= "bg.gif ";
}
</script>
<style type= "text/css ">
#nav li {
display: inline;
list-style-type: none;
padding: 5px 8px;
background-image:url(bg.gif);
font-size:16px;
}
</style>
</head>
<body>
<ul id= "nav ">
<li> <a href= "# " onMouseOver=chang(this) onMouseOut=nochang(this);> Div+CSS教程 </a> </li>
<li> <a href= "# " onMouseOver=chang(this) onMouseOut=nochang(this);> CSS布局实例 </a> </li>
<li> <a href= "# " onMouseOver=chang(this) onMouseOut=nochang(this);> CSS2.0教程 </a> </li>
<li> <a href= "# " onMouseOver=chang(this) onMouseOut=nochang(this);> CSS酷站欣赏 </a> </li>
<li> <a href= "# " onMouseOver=chang(this) onMouseOut=nochang(this);> CSS模板下载 </a> </li>
</ul>
</body>
</html>
但不行,望指教,谢谢!
------解决方案-------------------- <li onMouseOver= "chang(this) " onMouseOut= "nochang(this) "> <a href= "# "> Div+CSS教程 </a> </li>