Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
spencerchubb
on Oct 2, 2024
|
parent
|
context
|
favorite
| on:
TinyJS – Shorten JavaScript QuerySelect with $ and...
how would you add listeners if you were doing an html string? the first approach allows you to do something like this
``` const myButton = button({ onclick: e => console.log(e), textContent: "Click me" }) ```
TimTheTinker
on Oct 3, 2024
[–]
Use topElement.querySelector('button'), then add the listener programmatically.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
``` const myButton = button({ onclick: e => console.log(e), textContent: "Click me" }) ```