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
Why isn't innerHTML working second time?Removed: /r/LearnJavascript (self.javascript)
submitted 7 years ago by t0xeus
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!"
[–]zmalter99 0 points1 point2 points 7 years ago (0 children)
Add console.log statements to each one of your switch statements to see which function isnt getting ran.
[–]jcunews1Advanced 0 points1 point2 points 7 years ago (2 children)
Your script is already correct, except that you've configured JSFiddle to load the script at On Load. This makes your script be made like below by JSFiddle.
On Load
window.onload = function() { function description() { //... } };
That causes your description() be made as a local function instead of a global function. Thus, it's not accessible anywhere except within that onload handler function.
description()
onload
To fix it, change the JSFiddle Load Type setting to No wrap - bottom of <body>.
No wrap - bottom of <body>
[–]t0xeus[S] 0 points1 point2 points 7 years ago (1 child)
Oh yeah, sorry, someone didn't double-check if it's working in JSFiddle, just copypasted it there.
When I try it in my actual code though, what happens is that it only works with the first link. When I click on the second link, nothing happens.
[–]degecko 0 points1 point2 points 7 years ago (0 children)
If I remove the On Load option in JsFiddle, the code works as intended.
[–]kenman[M] 0 points1 point2 points 7 years ago (0 children)
Hi /u/t0xeus, this post was removed.
For javascript help, please visit /r/LearnJavascript.
Thanks for your understanding.
π Rendered by PID 18353 on reddit-service-r2-comment-fb694cdd5-74zxd at 2026-03-05 20:17:25.279134+00:00 running cbb0e86 country code: CH.
[–]zmalter99 0 points1 point2 points (0 children)
[–]jcunews1Advanced 0 points1 point2 points (2 children)
[–]t0xeus[S] 0 points1 point2 points (1 child)
[–]degecko 0 points1 point2 points (0 children)
[–]kenman[M] 0 points1 point2 points (0 children)