照著打的js文件卻沒(méi)效果出來(lái)??
function?bind(el,eventType,?callback){ ????if(typeof?el.addEventListener?===?"function"){ ???????????el.addEventListener(el,eventType,?callback,false); ????????}else?if(typeof?el.attechEvent?===?"function"){ ???????????el.attechEvent("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?=?targt.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();
然后HTML文件中引用就是這樣子:
<!DOCTYPE?html> <html> <head> <meta?charset="utf-8"> <link?rel="stylesheet"?type="text/css"?href="index.css"> <title>手風(fēng)琴效果</title> <script?type="text/javascript"?src="index.js"></script> </head> <body> 省略…… </body> </html>
監(jiān)聽(tīng)和縮放的效果都沒(méi)有出來(lái),為什么
2018-10-26
js引用放在</body>之前
2017-03-26
js引用要放在body中
2017-03-20
出來(lái)了嗎,我的也不行
2016-04-14
沒(méi)有運(yùn)行過(guò)試試 el.attechEvent拼寫(xiě)錯(cuò)誤 attachEvent?
target.tagName?==?"body" body大寫(xiě)試試BODY