Change the Value of h1 Element within a Form with JavaScript

Juan Doe picture Juan Doe · Mar 2, 2012 · Viewed 102k times · Source

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?

Answer

Sudhir Bastakoti picture Sudhir Bastakoti · Mar 2, 2012

Try:


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