猿问

请问为何定义完还是出现Cannot set property 'onmousedown' of undefined?

代码如下,做的是QQ面板那个课程

function getByclass(clsName,parent){

var oParent=parent?document.getElementById(parent):document,

eles=[],

elements=oParent.getElementsByTagName('*');

for(var i=0,l=elements.length;i<l;i++){

if(elements[i].classname==clsName){

eles.push(elements[i]);

}

}

return eles;

}


window.onload=drag;

function drag () {

var oTitle=getByclass('login_logo_webqq','loginPanel')[0];

oTitle.onmousedown=fnDown;

function fnDown() {

var oDrag=document.getElementById('loginPanel');

document.onmousemove=function(event){

event=event||window.event;

document.title=event.clientX+','+event.clientY;

}

}



庸俗的书生
浏览 2441回答 4
4回答

慕的地8582982

JGCFAGPYYEIVMWJCJJCFZWBHLOISIJISCPJCITDHETKKRAIUUUKVUHYRRDXYVYOEFTJWTZDXERHNSZLOJUNVVKKVAAMKKLVLHEUTUALEEEBNKBOGFPRZPFCADMJYPPJZGFFAWQZYTJZLEJCJTCFYJTDZGNEVHUVMHYEWDDNQTWMCTWFPKHJMMJPCRJSRTFFLGQCCZNYRNJWHUBQHXMCQSCTWMOSBOENJBQNJLOEOKZWMOEOXBDRAQGPTDTCYVHXMBRIEHQNQQUXAXHRNPXNOGVFJTQGIDGFPSIEUSVSIKIMOJZCSWSWTBSVXNXUWYISWGIZBLUWZJZSPYAQNWGALBXOYBRHFVXAWMBXOROFIYUKXHDTKGJMGDHFCZJXUWTVZPLORNDHEOYNEWMIKHRZKSPFFOYHDADGGYUOXTDLIMBRCLUXGPFHLVXHXYNKUKBWTVSCWADUENXAQMPLBDGCFVLURNKNCGCGQMOSIKTKKNEEEAARNQSVEHKTJGWPGDNBUJJCWAQJKGNROBVFPRUHYRVEBGUDSCPCYYISHPSOADNXQJGXXBZMMWENARHHHXBEDRNRNNGTLAEPBUVYHBKQMMWGSFPVFIOEDNIEEQJQDEKUCJMMJVMZTQZMHBRVVQADDUPPWZWCWNJZFNOITGJPFMWSLLMKCLCZSLZTDDHYYSDPGNKXEROKUJLDTGKXLLZGQAEUMTUJQGPKMYVYLFBJEKEDADIMTUCVWKZRPYPSTUZZMJNRCGWNSDVWJMCQBEPJRQOUSMXTQVZBCGAIQVPZXTCOGAEXZPPJYIDJGPSYPLOIREORRALQABWQWOTUVMHDGKNREKAABRVPGPPNTGCZXMZUGUTMDZPTGGOYBMAQVSSYIBEAI

慕粉1628116899

获取元素的class: element.className 而非classname, 如marginTop,backgroundColor, 元素的css属性在JS中多是这种方式指代。
随时随地看视频慕课网APP
我要回答