{"id":10120,"date":"2026-04-23T15:06:24","date_gmt":"2026-04-23T14:06:24","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=10120"},"modified":"2026-04-23T15:06:26","modified_gmt":"2026-04-23T14:06:26","slug":"javascript-event-preview","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/javascript-event-preview\/","title":{"rendered":"Javascript Event Preview"},"content":{"rendered":"\n<p>Use Event Capturing (<code>{ capture: true }<\/code>)&nbsp;<\/p>\n\n\n\n<p>By default, listeners use event bubbling (run last). If you set the <code>capture<\/code> option to <code>true<\/code> in <code>addEventListener<\/code>, your handler will execute during the capturing phase, which happens <em>before<\/em> the target phase and bubbling phase.&nbsp;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">element.addEventListener('click', (e) => {\n  console.log('I run first!');\n}, { capture: true });\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Event Capturing ({ capture: true })&nbsp; By default, listeners use event bubbling (run last). If you set the capture option to true in addEventListener, your handler will execute during the capturing phase, which happens before the target phase and bubbling phase.&nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10120","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/10120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=10120"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/10120\/revisions"}],"predecessor-version":[{"id":10121,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/10120\/revisions\/10121"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=10120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=10120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=10120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}