To change label text using JavaScript, we set the innerHTML
property.
For instance, we write
<label id="lbltipAddedComment">test</label>
to add a label element.
Then we write
document.getElementById("lbltipAddedComment").innerHTML =
"your tip has been submitted!";
to select the element with getElementById
.
And then we set innerHTML
property with the new label text to update it.