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?
Try:
document.getElementById("yourH1_element_Id").innerHTML = "yourTextHere";
You can use this: document.getElementById('h1_id').innerHTML = 'the new text';
document.getElementById('h1_id').innerHTML = 'the new text';
document.getElementById("myh1id").innerHTML = "my text"
:
document.getElementById("your_h1_id").innerHTML = "your new text here"
JavaScript :
document.getElementById('h1_id').innerHTML = 'h1 content here';
getElementById innerHTML.
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.