首页 新闻 会员 周边 捐助

js 鼠标移过更换图片

0
悬赏园豆:10 [已关闭问题] 关闭于 2011-04-26 16:22

js   code...............................................................................................................................

function mouse_over(self,flag)
{
    var item_id = document.getElementById("menubars_div").document.getElementsByTagName("div");
    if(item_id != null)
    {
        for(var i = 1;i<= item_id.length;i++)
        {
            if(flag == i)
            {
                alert(self);
                self.style.backgroundImage = "../images/menubar.jpg";
            }
        }
    }
}

html code....................................................................................................................................

<div class="menubars_div" id="menubars_div">
                <div id="menu1" class="menubar" onmouseover="mouse_over(this,1);" onmouseout="mouse_out(this,1);"><a href="#">网站首页</a></div>
                <div id="menu2" class="menubar" onmouseover="mouse_over(this,2);" onmouseout="mouse_out(this,2);"><a href="#">走进建盟</a></div>
                <div id="menu3" class="menubar" onmouseover="mouse_over(this,3);" onmouseout="mouse_out(this,3);"><a href="#">产品展示</a></div>
                <div id="menu4" class="menubar" onmouseover="mouse_over(this,4);" onmouseout="mouse_out(this,4);"><a href="#">经典工程</a></div>
                <div id="menu5" class="menubar" onmouseover="mouse_over(this,5);" onmouseout="mouse_out(this,5);"><a href="#">营销网络</a></div>
                <div id="menu6" class="menubar" onmouseover="mouse_over(this,6);" onmouseout="mouse_out(this,6);"><a href="#">客户留言</a></div>
                <div id="menu7" class="menubar" onmouseover="mouse_over(this,7);" onmouseout="mouse_out(this,7);"><a href="#">人才招聘</a></div>
                <div id="menu8" class="menubar" onmouseover="mouse_over(this,8);" onmouseout="mouse_out(this,8);"><a href="#">联系我们</a></div>
            </div>

我弹出self的参数的时候,值为object  htmldivelement,明明是有值,为什么js总是报self为空。而且图片还更换不成功。

路过春秋的主页 路过春秋 | 初学一级 | 园豆:10
提问于:2011-04-26 16:18
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册