Change the Value of h1 Element within a Form with JavaScript

137,834

Solution 1

Try:


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

Solution 2

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

Solution 3

document.getElementById("myh1id").innerHTML = "my text"

Solution 4

You may try the following:

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

Solution 5

You can also use this

document.querySelector('yourId').innerHTML = 'Content';
Share:
137,834

Related videos on Youtube

Juan Doe
Author by

Juan Doe

Updated on May 13, 2022

Comments

  • Juan Doe
    Juan Doe about 2 years

    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?

  • Hidayt Rahman
    Hidayt Rahman about 5 years
    Why the repeated answer?