domhtml
document.getElementById(id).innerHTML 改變文本cookie
document.write(date()) 文檔流輸出當前日期app
document.getElementById(id).src='地址' 改變圖片地址dom
document.getElementById(id).style.color="顏色" js 改變顏色ui
document.getElementById('p1').style.visibility.hidden/visiblethis
fun(this)xml
function fun(id)htm
{事件
id.innerTHML='新值'圖片
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<p>請點擊如下的按鈕</p>
<button onclick="fun()" >點擊這裏</button>
<script>
function fun() {
document.getElementById("mode").innerHTML = Date();
}
</script>
<p id="mode"></p>
</body>
</html>
MOD
var aaa = document.createElement("p");
var bbb = document.createTextNode("這是一個新段落");
aaa.appendChild(bbb);
var div = document.getElementById("bba");
div.appendChild(aaa);
onload 和 onunload 事件
<body onload="check()">
<script>
function check() {
if (navigator.cookieEnabled == null) {
alert("已經啓用了cookie");
}
else {
alert("沒有啓用cookie");
}
}