读书人

上句jquery 换成js 得如何写

发布时间: 2012-09-17 12:06:52 作者: rapoo

下句jquery 换成js 得怎么写啊
下句jquery 换成js 得怎么写啊

$(function () {
$("li:has(ul)").hover(
function () {
$(this).children("ul").show();
},
function () {
$(this).children("ul").hide();
})
})

[解决办法]

JScript code
window.onload=function(){      var dom=document.getElementsByTagName("li");      for(var i=0;i<dom.length;i++){         if (dom[i].childNodes.length > 0)        {            for (var j=0,l=dom[i].childNodes.length;j<l ;j++ )            {                if (dom[i].childNodes[j].tagName == "UL")                {                    dom[i].onmouseover=function(){                         for (var i=0,l=this.childNodes.length;i<l ;i++ )                        {                            if (this.childNodes[i].tagName == "UL")                            {                                this.childNodes[i].style.display='';                            }                        }                    }                    dom[i].onmouseout=function(){                         for (var i=0,l=this.childNodes.length;i<l ;i++ )                        {                            if (this.childNodes[i].tagName == "UL")                            {                                this.childNodes[i].style.display='none';                            }                        }                    }                }                                     }        }               }    } 

读书人网 >asp.net

热点推荐