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>
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!