Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="C">c
  <div id="B">b
    <div id="A">a</div>
  </div>
</div>
</body>
</html>
 
div{
  border: 1px solid ;
  margin: 20px;
}
 
//先捕获(true),再同一个绑定对象顺序,最后冒泡
A.addEventListener('click',function(){
  console.log('1a')
})
A.addEventListener('click',function(){
  console.log('2a,true')
},true)
B.addEventListener('click',function(){
  console.log('1b,true')
},true)
B.addEventListener('click',function(){
  console.log('2b')
})
C.addEventListener('click',function(){
  console.log('1c')
})
C.addEventListener('click',function(){
  console.log('2c')
})
C.addEventListener('click',function(){
  console.log('3c,true')
},true)
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers