Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> </head> <body> <button id="buttonId">Click on button</button> <script> buttonId.onclick = function() { alert("one"); // alert(2) setTimeout(() => buttonId.dispatchEvent(new CustomEvent("menuOpen", { bubbles: true }))); alert("two"); }; document.addEventListener('menuOpen', () => alert('nested')); </script> </body> </html>