当前位置: 代码迷 >> ASP.NET >> 上句jquery 换成js 得如何写
  详细解决方案

上句jquery 换成js 得如何写

热度:8851   发布时间:2013-02-25 00:00:00.0
下句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';                            }                        }                    }                }                                     }        }               }    }
  相关解决方案