javascript控制background属性来改变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>
------解决方案--------------------objThis.style.backgroundImage= "newsobg.gif ";
改成:
objThis.style.backgroundImage= "url(newsobg.gif) ";