# Sp-button onclick does not work

**URL:** <https://forums.creativeclouddeveloper.com/t/sp-button-onclick-does-not-work/3093>\
**Category:** UXP Plugin API\
**Created:** [June 14, 2021, 7:46pm UTC](https://forums.creativeclouddeveloper.com/t/sp-button-onclick-does-not-work/3093 "2021-06-14T19:46:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [June 14, 2021, 7:46pm UTC](https://forums.creativeclouddeveloper.com/t/sp-button-onclick-does-not-work/3093/1 "2021-06-14T19:46:45Z")

</div>

In my dialog I have

```auto
<sp-button onclick="console.log(1)">Close</sp-button>

```

But clicking on it does absolutely nothing. Tried moving button up to the root `<dialog>` element, but no luck. Any ideas?

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [June 14, 2021, 7:58pm UTC](https://forums.creativeclouddeveloper.com/t/sp-button-onclick-does-not-work/3093/2 "2021-06-14T19:58:21Z")

</div>

Wonder if this could be some bug, when dialog is created in JS and not in HTML 🤔

```auto
    const dialog = document.createElement('DIALOG');
    dialog.innerHTML = dialogContents;
    document.body.appendChild(dialog);

    dialog.querySelector('sp-button').addEventListener('click', () => {
        dialog.close();
    });

```

Adding event listener like this, works perfectly fine 🙄

---

<div class="post-metadata">

**Author:** ![kerrishotts](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kerrishotts/32/8_2.png) [@kerrishotts](https://forums.creativeclouddeveloper.com/u/kerrishotts)\
**Post date:** [June 15, 2021, 3:56pm UTC](https://forums.creativeclouddeveloper.com/t/sp-button-onclick-does-not-work/3093/3 "2021-06-15T15:56:13Z")

</div>

This is the intended pattern – inline event handlers are not supported.
