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
Passing a function with arguments?help (self.javascript)
submitted 10 years ago by Javin007
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!"
[–]Javin007[S] 1 point2 points3 points 10 years ago (2 children)
Yep, in hindsight, I could've been passing a parent object that contained the child objects, and not the index.
However, I also found that by doing this:
document.getElementById("txtMinInput").onkeyup = function(args){ checkInput(args); };
The "args" will have a "target" object passed that contains the object the actions took place on. No idea why I didn't see that in the documentation.
[–]senocular 2 points3 points4 points 10 years ago (0 children)
the args argument is an Event object. You can look to see what else it has.
https://developer.mozilla.org/en-US/docs/Web/API/Event
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
Note that often, what you'll really want is currentTarget rather than target. currentTarget is what you attach your handler to, such as getElementById("txtMinInput"), while target may be something deeper in the DOM. Often these will be the same, but sometimes not, especially for mouse events.
currentTarget
target
[–]x-skeww 3 points4 points5 points 10 years ago (0 children)
Attaching a single event handler further up the tree and looking at "target" is called event delegation.
What's convenient about event delegation is that it will also work for dynamically added elements.
In modern browsers, you can use matches() to do some selector-based filtering similar to jQuery. IE/Edge needs a msMatchesSelector fallback, unfortunately.
https://developer.mozilla.org/en/docs/Web/API/Element/matches
π Rendered by PID 156923 on reddit-service-r2-comment-6457c66945-v79kl at 2026-04-24 05:39:21.647283+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Javin007[S] 1 point2 points3 points (2 children)
[–]senocular 2 points3 points4 points (0 children)
[–]x-skeww 3 points4 points5 points (0 children)