Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const btn = document.querySelector('#myButton'); function handleClick(event) { console.log('Clicked!', event.target); console.log('Event type:', event.type); } btn.addEventListener('click', handleClick); btn.removeEventListener('click', handleClick); btn.addEventListener('click', function() { console.log('Fires once'); }, { once: true }); window.addEventListener('resize', function() { console.log('Window width:', window.innerWidth); });
Result
Open