Skip to content
Advertisement

Change the Value of h1 Element within a Form with JavaScript

I have two forms on an HTML5 page. Each form has a name and an id. The second form has an h1 element, which also has a name and an id. How do I change the text of this h1 element on the second form using plain JavaScript?

Advertisement

Answer

Try:


document.getElementById("yourH1_element_Id").innerHTML = "yourTextHere";

Advertisement