其中if(oSubNav)的作用是什么?直接調(diào)用值嗎?還是怎么的?
aLi[i].onmouseout = function() {
? ? ? ? ? ? ? ? // 建立列表
? ? ? ? ? ? var oSubNav=this.getElementsByTagName('ul')[0];
? ? ? ? ? ? // 設(shè)置oSubNav為零
? ? ? ? ? ? // 判斷
? ? ? ? ? ? if(oSubNav){
? ? ? ? ? ? var This=oSubNav;
? ? ? ? ? ? clearInterval(This.time);
? ? ? ? ? ? This.time=setInterval(function(){
? ? ? ? ? ? ? ? ? ? This.style.height=This.offsetHeight-16+"px";
? ? ? ? ? ? ? ? ? ? if(This.offsetHeight<=0){
? ? ? ? ? ? ? ? ? ? ? ? This.offsetHeight = 0;
? ? ? ? ? ? ? ? ? ? ? ? clearInterval(This.time);
? ? ? ? ? ? ? ? ? ? } ?
? ? ? ? ? ? ? ? },30)
? ? ? ? ? ? ?} ? ?
2017-03-19
普通判空作用,防止取到的onSubNav值為undefine空的情況,避免JS解釋器報(bào)錯(cuò),瀏覽器掛掉。