Source Code:
(back to article)
Submit
Result:
Report an issue
<div id="outer"></div> <script> const outer = document.getElementById('outer'); const shadow = outer.attachShadow({ mode: 'open' }); const button = document.createElement('button'); button.textContent = 'Click me'; button.addEventListener('click', event => { const composedInfo = document.createElement('p'); composedInfo.textContent = `Composed: ${event.composed}`; shadow.appendChild(composedInfo); }); shadow.appendChild(button); </script>