Home  >  Article  >  Web Front-end  >  How to modify div content with javascript

How to modify div content with javascript

coldplay.xixi
coldplay.xixiOriginal
2021-03-31 14:31:459985browse

How to modify the content of a div using JavaScript: First add the id and text content to the tag and create a [

How to modify div content with javascript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

How to modify div content using JavaScript:

1. Open the HTML development tool, create a new HTML page, then create a

tag and add an id to the tag. and text content.

How to modify div content with javascript

#2. Save the html code and open it with a browser. You can see that the page displays the text content in the div tag.

How to modify div content with javascript

3. Return to the html code page, create a

JavaScript code:

document.getElementById("demo").innerHTML = "hello world";

How to modify div content with javascript

4. Save the html code, and then open it with a browser to see that the browser page is modified using JavaScript text.

How to modify div content with javascript

Related free learning recommendations: javascript learning tutorial

The above is the detailed content of How to modify div content with 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