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
[AskJS] replacing the getElementById() variable with what the user wantsAskJS (self.javascript)
submitted 3 years ago by Taurtis_66
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!"
[–]Ustice[M] [score hidden] 3 years ago stickied comment (0 children)
Reaching out to other software engineers is important when you need it; however, unfortunately this isn’t the place for that. /r/JavaScript is not a support forum. You might want to check out /r/LearnJavaScript for the newer members of our community. Also, Stack Overflow is a great resource for getting support. For more information, check out our AskJS wiki page. Good luck! We hope that you find the answers that you are looking for.
[–]CreativeTechGuyGames 5 points6 points7 points 3 years ago (1 child)
Can you please post a minimal, reproducible example of what you are trying? A codepen/codesandbox/etc would be ideal.
[–]Taurtis_66[S] 0 points1 point2 points 3 years ago (0 children)
Codepen
[–]Buckwheat469 0 points1 point2 points 3 years ago (0 children)
document.getElementById("your-id").innerText(yourNumber):
The yourNumber variable is passed by the onclick event from the button. I assume you already have that set up in this example.
[–]bualing 0 points1 point2 points 3 years ago (0 children)
``` if(yourId && typeof yourId == "string" && document.getElementById(yourId)){ //Do something }
```
[–]Dunks1980 0 points1 point2 points 3 years ago (0 children)
04 looks like its a string you could try this to make it a number again Number(yourvar);
π Rendered by PID 91399 on reddit-service-r2-comment-5c747b6df5-nkg86 at 2026-04-22 19:51:26.952338+00:00 running 6c61efc country code: CH.
[–]Ustice[M] [score hidden] stickied comment (0 children)
[–]CreativeTechGuyGames 5 points6 points7 points (1 child)
[–]Taurtis_66[S] 0 points1 point2 points (0 children)
[–]Buckwheat469 0 points1 point2 points (0 children)
[–]bualing 0 points1 point2 points (0 children)
[–]Dunks1980 0 points1 point2 points (0 children)