Home > Web Front-end > JS Tutorial > body text

How to change the original content of html through js

不言
Release: 2018-06-12 14:33:08
Original
2040 people have browsed it

The following will bring you a method to implement js to change the original content of html. The content is quite good, so I will share it with you now and give it as a reference.

is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js改变html的内容</title>
<!-- 不能把JavaScript写在这个头部来改变html的内容-->
</head>

<body>
<!-- 不能把JavaScript写在定义pid的前面来改变html的内容-->
<p id="pid">Hello Html!</p>
<script type="text/javascript">
	document.getElementById("pid").innerHTML="绝地反击";//js改变html的内容
</script>
</body>
</html>
Copy after login

The above is The entire content of this article is hoped to be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use DOM in JS to control HTML elements

How to use js to splice html strings

The above is the detailed content of How to change the original content of html through js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template