Q) 我的观点是,每当我在两种情况下都将 addEventListener 的最后一个参数设置为 true 或 false 时,事件目标 (e.target) 保持不变,即 img,在下面的代码中你可以看到我将最后一个参数设置为 true,这意味着捕获但仍在 console.log 气泡中是真的,这让我很困惑
document.querySelector('.grid').addEventListener('click', function (e) {
console.log(e);
console.log(e.target + " " + this.className);
},true)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript Events</title>
<link href='http://fonts.googleapis.com/css?family=Bree+Serif|Merriweather' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="art">
<h2>Art Eliminator</h2>
<p>Pick your favorite piece of art through the process of elimination. Click on the pieces you like the least until you are left with a single one. Click on the last image to get some info</p>
<ul class="grid">
<li><img src="images/Hassum_Harrod_03_tn.jpg" alt="Hassum Harod's Summer Trees"></li>
<li><img src="images/LaVonne_LaRue_02_tn.jpg" alt="LaVonne LaRue's Mighty Duck"></li>
<li><img src="images/Lorenzo_Garcia_01_tn.jpg" alt="Lorenzo Garcia's The Dancer"></li>
<li><img src="images/Jennifer_Jerome_01_tn.jpg" alt="Jennifer Jerome's A day of Rest'"></li>
<li><img src="images/Constance_Smith_03_tn.jpg" alt="Constance Smith's Letterforms"></li>
<li><img src="images/LaVonne_LaRue_04_tn.jpg" alt="LaVonne LaRue's Flow"></li>
<li><img src="images/Lorenzo_Garcia_03_tn.jpg" alt="Lorenzo Garcia's Mother"></li>
<li><img src="images/Jennifer_Jerome_02_tn.jpg" alt="Jennifer Jerome's Farm Life"></li>
<li><img src="images/Hillary_Goldwynn_03_tn.jpg" alt="Hillary Goldwynn's Blue Sky"></li>
</ul>
</div>
<script src="script.js"></script>
</body>
</html>