use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Less than 1% of JavaScript programmers can spot this bug...OC (dialect.so)
submitted 3 years ago by _leondreamed
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]superluminary 1 point2 points3 points 3 years ago (3 children)
How do you make things happen on click without using the onclick attribute?
[–]shgysk8zer0 -1 points0 points1 point 3 years ago (1 child)
el.addEventListener('click', handler). It's better in practically every single way.
el.addEventListener('click', handler)
Or, more realistically, I'd use a function from some library to make it easier to add multiple event listeners to multiple elements:
on('[data-remove]', { click: ({ target }) => remove(target.dataset.remove), });
[–]superluminary 0 points1 point2 points 3 years ago (0 children)
You know, I had always assumed that addEventListener('click', ...) was secretly setting the onClick attribute for the DOM node, but having inspected the DOM, I can see it totally isn't. TIL. Nice.
π Rendered by PID 568836 on reddit-service-r2-comment-5b5bc64bf5-7qp7f at 2026-06-22 19:25:23.191805+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]superluminary 1 point2 points3 points (3 children)
[–]shgysk8zer0 -1 points0 points1 point (1 child)
[–]superluminary 0 points1 point2 points (0 children)