谁能告诉我innerHTML在javascript中的作用,并举例说明如何使用它?
最佳答案
The innerHTML
property用于获取或设置 element 节点的 HTML content。
示例: http://jsfiddle.net/mQMVc/
// get the element with the "someElement" id, and give it new content
document.getElementById('someElement').innerHTML = "<p>new content</p>";
// retrieve the content from an element
var content = document.getElementById('someElement').innerHTML;
alert( content );
关于javascript - innerHTML 在 JavaScript 中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4879066/