Home  >  Article  >  Web Front-end  >  How to modify h2 title in javascript

How to modify h2 title in javascript

青灯夜游
青灯夜游Original
2021-12-07 15:03:383466browse

Method: 1. Use the "document.getElementById("id value")" statement to obtain the h2 element object based on the id value; 2. Use "h2 element object.innerHTML="new title content"" or "h2 Element object.innerText="New title content"" statement can be modified.

How to modify h2 title in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

In javascript, if you want to modify the content of a tag, you can use:

  • innerHTML attribute

  • innerText attribute

Implementation code:

旧h2标题内容

How to modify h2 title in javascript

[Related recommendations: javascript learning tutorial]

The above is the detailed content of How to modify h2 title in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn