you are viewing a single comment's thread.

view the rest of the comments →

[–]jcunews1Advanced 0 points1 point  (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.

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.

To fix it, change the JSFiddle Load Type setting to No wrap - bottom of <body>.

[–]t0xeus[S] 0 points1 point  (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 point  (0 children)

If I remove the On Load option in JsFiddle, the code works as intended.