Home>Article>Web Front-end> How to modify div content with javascript
Javascript method to modify div content: First use the "document.getElementById('id value')" statement to obtain the div object according to the id value; then use the innerHTML attribute to modify the div content, the syntax "div object.innerHTML=' value'".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
Javascript method to modify div content:
html code:
将要被修改的div
js code:
Description:
The getElementById() method returns a reference to the first object with the specified ID.
The innerHTML property sets or returns the HTML between the opening and closing tags of a table row.
[Recommended learning:javascript advanced 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!