Home > Article > Web Front-end > How to replace div content with javascript
How to replace div content with JavaScript: 1. Define a div node; 2. Get the div node; 3. Replace the div content with "dt.innerHTML = "abc";".
The operating environment of this article: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
How to replace div content with javascript?
Replace content by updating innerHTML information
1. Define a div node
<div id='test'>123</div>
2. Obtain the div node
var dt = document.getElementById('test');//通过id获取该div
3. Replace the content of the div
dt.innerHTML = "abc";//把123替换成abc
Recommended study: "javascript basics Tutorial》
The above is the detailed content of How to replace div content with javascript. For more information, please follow other related articles on the PHP Chinese website!