日期:2014-05-16  浏览次数:20343 次

请问这样的函数怎么绑定??
document.getElementById("db").onmousedown=function(){
  alert(1)
  document.getElementById("db").onmousemove=function(){}
  document.getElementById("db").onmouseup=function(){}
}


我为什么这么问是因为

document.getElementById("aa").innerHTML="<div id='db'></div>";

有这种情况

而绑定是
addEventListner("mousedown",fn,false)

这个fn在这种情况下非常难办了

------解决方案--------------------
老老实实用createElement做就好了
------解决方案--------------------
function init(){
var a="cmls";
document.getElementById("test").attachEvent("onclick",function(){ss(a)});
}
function ss(a){
alert(a);
}
这样试试