Home>Article>Web Front-end> How to change page text in javascript

How to change page text in javascript

藏色散人
藏色散人 Original
2021-06-27 09:51:21 2984browse

How to change the page text in JavaScript: First find the js code part; then modify the text content on a certain div through "var y=document.getElementById("header");y.innerHTML=name;" .

How to change page text in javascript

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

How to change page text in javascript?

Use javascript to modify the text content on a certain div

Today when I am doing javascript, I need to modify the content of a certain div.

The code is as follows

var y=document.getElementById("header"); y.innerHTML=name;

The header is the id of the div you want to modify. If not, just add the id attribute.

name is text content

[Recommended:javascript advanced tutorial]

The above is the detailed content of How to change page text 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
Previous article:How to format javascript Next article:How to format javascript