<html>
<head>
<title>example</title>
</head>
<body>
<div id="div1">Click Me</div>
<script type="text/javascript">
var fnClick1=function () {
alert("click");
}
var fnClick2=function () {
alert("alsoclick");
}
var oDiv=document.getElementById("div1");
oDiv.attachEvent("onclick", fnClick1);
oDiv.attachEvent("onclick", fnClick2);
</script>
</body>
</html>
怎么先输出alsoclick 然后才是click呢?

解决方案 »

  1.   

    用attachEvent添加的事件,DOM是乱序解释
      

  2.   

    连分都没有,那我就不给翻译了阿,下面是对于attachEvent方法的官方说明
    When sEvent fires on the object, the object's sEvent handler is called before fpNotify , the specified function. If you attach multiple functions to the same event on the same object, the functions are called in random order, immediately after the object's event handler is called.