Change h1 element value in form using javascript

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

+9
source share
5 answers

Try:


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

+35
source

You can use this: document.getElementById('h1_id').innerHTML = 'the new text';

+5
source
document.getElementById("myh1id").innerHTML = "my text"
+4

:

document.getElementById("your_h1_id").innerHTML = "your new text here"
+2

JavaScript :

document.getElementById('h1_id').innerHTML = 'h1 content here';

getElementById innerHTML.

innerHTML:

A DOMString string containing the HTML serialization of the children of the element. Setting the innerHTML value deletes all descendants of the element and replaces them with nodes created by parsing the HTML specified in the htmlString string.

0
source

All Articles