猿问

手风琴JS代码在谷歌上运行不起来

function bind(el,eventType,callback){

  if(typeof el.addEventListener === 'function'){

  el.addEventListener(el,eventType,callback, false);

  }else if(typeof el.attechEvent === 'function'){

   el.attachEvent('on' + eventType, callback);

  }

}

function mouseoverHandler(e){

    var target = e.target || e.srcElement;

    var outer = document.getElementById('subject');

    var list = outer.getElementsByTagName('li');


    for(var i = 0; i < list.length; i++){

    list[i].className = '';

    }

      while(target.tagName != 'LI' || target.tagName == 'BODY'){

      target = target.parentNode;

      }


      target.className = 'big';

}


function initList(){

var outer = document.getElementById('subject');

var list = outer.getElementsByTagName('li');

for(var i =0;i < list.length; i++){

bind(list[i],'mouseover', mouseoverHandler);

}

}


initList();



求老师指点

默默模式
浏览 1030回答 1
1回答

李晓健

看上一条提问的回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答