Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 520
Juan Doe Avatar asked Mar 02 '12 07:03

Juan Doe


People also ask

How do I change text in h1 tag?

How to Change Font Type in HTML. To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.

Can the element h1 be replaced with h1?

Your H1 heading and page title can be different, or the exact same — both are fine, as long as they work both for visitors and search engines. For example, if you want to use a slightly different H1 heading for visitors to better convey the main topic of a page, by all means go for it. It's totally fine.

What is h1 in JavaScript?

Definition and Usage. The <h1> to <h6> tags are used to define HTML headings. <h1> defines the most important heading. <h6> defines the least important heading.

Is h1 an element or tag?

The HTML <h1> tag defines the highest level or most important heading in the HTML document. This tag is also commonly referred to as the <h1> element.


1 Answers

Try:

  document.getElementById("yourH1_element_Id").innerHTML = "yourTextHere";  
like image 126
Sudhir Bastakoti Avatar answered Sep 25 '22 22:09

Sudhir Bastakoti