document.getElementById(id).innerHTML = new HTML
示例:改变元素的HTML内容
<p id="demo"></p> <script> document.getElementById("demo").innerHTML = "<h3>666</h3>反清复明"; </script>
document.getElementById(id).attribute = new value
示例:设置HTML元素的属性值
// 改变指定图片元素的src属性 function change_src() { document.getElementById("image").src = "https://logo.zhuanfou.com/mongodb.png"; }