Here is my code looks like, I would like to be able to use whatever user inputs as the value for my showColor function. I used document.getElementsByName, but I got some errors Type error. Can somebody help? Thanks!
<input type="text" name="color" value="Input Your Fav Color">
<button type="button" onClick="showColor('red')">Show Color</button>
I’m guessing it’s because you’re doing this
You should be doing this instead
Because
getElementsByNamereturns a collection, or alternatively give the element anidand usegetElementByIdinstead.