const box = document.getElementById('box');
// 👇️ add 2 event listeners
box.addEventListener('click', function handleClick() {
console.log('box clicked first');
});
box.addEventListener('click', function handleClick() {
console.log('box clicked second');
});
// ✅ Remove event listeners from Element
box.replaceWith(box.cloneNode(true));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter