weibo_时间煮雨我煮面022_0
2016-07-07 11:35
function drag(){
var oTitle=getByClass('top','main')[0]; //调用封装函数
oTitle.onmousedown=fnDown; //绑定onmousedown事件,当按下鼠标时调用fnDown函数
}
//封装fnDown函数
function fnDown(){
document.onmousemove=function(event){
event=event||window.event;
document.title=event.clientX+','+event.clientY;
}
}
可能是你的oTitle下的元素因为设置了onmousedown事件,但是你没有关闭事件冒泡,元素的事件冒泡到oTitle导致错误!希望有用!!
var oTitle=getByClass('top','main')[0];
getByClass('top','main') 里面两个参数一个应该是class 用字符串传入,一个是父级对象不应该用字符串传入,这样你的class对象没法获取,所以你的onmousedown属性没对象
DOM事件探秘
99532 学习 · 1298 问题
相似问题