@rauschmaAxel Rauschmayer Glad you asked! πŸ˜‚

The simplest answer would be:

`this.querySelector("button")…`

which works when `this` is the custom element your JS code is housed in.

```html
<my-ui-element>
<button>Click me!</button>
</my-ui-element>
```

For defensive coding, you can scope your selector even further:

`this.querySelector(":scope > button”)`

so it doesn't bug out when some other button of a child component shows up.

Handling multiple buttons though? There are still options besides using id

0

If you have a fediverse account, you can quote this note from your own instance. Search https://intuitivefuture.com/users/vanillaweb/statuses/114700030176491552 on your instance and quote it. (Note that quoting is not supported in Mastodon.)