JavaScript Parameter problem

I'm trying to test something with parameters

So I made 2 headers 1st one with the the id="test1" and the second one with the id="test2", then underneath that I have to links the 1st one goes to #test1 and the 2nd one goes to #test2 and call the function changeColor(), but the function calls a parameter so it would be changeColor(test1) for the 1st link. This is the code for the function:

It doesn't work though. I did try this too:

And that actually worked but only for the second header. The only reason I tried this was bc I accidently did this in another repl and it worked.

If you look in script.js it has all of the functions but only the 1st one is not commented out.

Please help

P.S. If you want to help I would recommend forking it and uncommenting the functions to understand what's going on.

You are viewing a single comment. View All

In the onclick function, you have to pass in the parameter as a string:


Thank you! @OldWizard209 you deserves some cycles!


No problem mate. It was a simple problem tbh. @cuber1515


True, but it was causing me a big problem in another repl, @OldWizard209