一个二级导航的问题。 因为一级导航和二级导航之间有空隙 所以我想用延迟执行那个语句来弄。。可是不行 不知道是哪里写错了
<style>
*{ margin:0px; padding:0px;}
ol,ul,li{ list-style:none;}
.demo{ background:url(images/demo6.jpg) no-repeat; width:520px; height:36px; margin:100px auto;}
.demo ul{ width:508px; padding-left:12px;}
.demo ul li{ float:left; text-align:center; font-size:12px; width:78px; float:left; line-height:36px; position:relative; color:#fff; cursor:pointer;}
.demo ul li p{ position:absolute; left:0px; top:50px; width:280px; text-indent:12px; background:url(images/demo7.jpg) no-repeat; display:none; color:#666;}
</style>
<script type="text/javascript">
window.onload=function ()
{
var d=document.getElementById('demo');
var a=d.getElementsByTagName('li');
var p=d.getElementsByTagName('p');
var i=0;
var timer=null;
for(i=0;i<a.length;i++)
{
a[i].index=i;
a[i].onmousemove=function ()
{
for(i=0;i<a.length;i++)
{
a[i].style.background='';
p[i].style.display='';
}
p[this.index].style.display='block';
this.style.background='url(images/demo8.jpg) center no-repeat';
};
a[i].onmouseout=function ()
{
timer=setTimeout(function (){
this.style.background='';
p[this.index].style.display='none';
}, 300);
};
}
};
</script>