聘我网

新概念招聘3.0

问个js事件模型的问题

vote up0vote downstar
<input type="button"  id ="button1" value="Click Me" onclick="alert('button')" />  

这里面的click事件处理函数会在 bubbling phase还是capture phase 执行? 在dom兼容浏览器里面

 

1 个答复

vote up0vote down

一般都是bubble阶段,用这段代码测试一下就知道了:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html lang="en"> 
<head>
  <title>Event order test page</title>
</head>
  <body>
    <div onclick="alert('outer')">
      <div onclick="alert('inner')">
        *************
      </div>
    </div>
  </body>
</html>
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.