@vanillawebThat HTML Blog & The Spicy Web well, what should I do instead?
@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
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.)