Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Javascript function paramenters

I am confused on a task I have been given:

Function: takes 2 parameters, a string and a label id and writes the string value to the text of the label

• Example:

changeLabel('mylabel1', ‘label1’);

should change the text value of

‘<label id="label1">Form Label1</label>’ 

to

‘<label id="label1">mylabel1</label>’

I am not sure where to put the variables which need to be passed in, here is my code but it will not validate when it is tested.

function changeLabel('mylabel1', 'label1'){
 document.getElementById("label1").innerHTML = mylabel1;
}
changeLabel('mylabel1', 'label1');

Can someone please help?

Answer*

Draft saved
Draft discarded
Cancel
0

lang-js

AltStyle によって変換されたページ (->オリジナル) /