https://blog.csdn.net/zhuhuangtianzi/article/details/24712329
document.write(Date()); //在输入流中直接写
document.getElementById(id).innerHTML=new HTML //改变已经有的元素内容
document.getElementById("image").src="landscape.jpg"; //改变属性值
2 改动CSS的值
document.getElementById(id).style.property=new styledocument.getElementById("p2").style.color="blue"; //改变颜色
onclick="document.getElementById(‘p1‘).style.visibility=‘visible‘" /> //改变可见性
3 对事件作出反应
HTML DOM 使 JavaScript 有能力对 HTML 事件做出反应。<head>
<script>
function changetext(id)
{
id.innerHTML="谢谢!";
}
</script>
</head>
<body>
<h1 onclick="changetext(this)">请点击该文本</h1>
</body>
<script>
document.getElementById("myBtn").onclick=function(){displayDate()};
</script>
<4> javaScript中加入事件
这个须要注意的是,函数后面不能加入括号()。<!DOCTYPE html>
<html>
<body>
<div id="div1">
<p id="p1">这是一个段落。</p>
<p id="p2">这是还有一个段落。</p>
</div>
<script>
var para=document.createElement("p");
var node=document.createTextNode("这是新段落。");
para.appendChild(node);
var element=document.getElementById("div1");
element.appendChild(para);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<div id="div1">
<p id="p1">这是一个段落。</p>
<p id="p2">这是还有一个段落。</p>
</div>
<script>
var parent=document.getElementById("div1");
var child=document.getElementById("p1");
parent.removeChild(child);
</script>
</body>
</html>
原文:https://www.cnblogs.com/xfgnongmin/p/10809469.html