JS:網(wǎng)頁腳本語言;與Java是兩個品種
1>JS常見的書寫方式
1.1 頁內JS:在當前網(wǎng)頁的script標簽中編寫
<script type="text/javascript">
</script>
1.2 外部JS
<script src="index.js"></script>
JS的Dom操作對象
1>window
1.1 所有全局的變量都是window的變量
1.2 所有全局的函數(shù)都是window的函數(shù)

window
動態(tài)的跳轉網(wǎng)頁:window.location.href='http://www.baidu.com';
2>document對象
2.1 動態(tài)的獲取網(wǎng)頁中所有的節(jié)點
2.2 可以動態(tài)的對節(jié)點進行CRUD
2.3 CRUD是指在做計算處理時的增加(Create)、查詢(Retrieve)(重新得到數(shù)據(jù))、更新(Update)和刪除(Delete)幾個單詞的首字母簡寫

對節(jié)點進行增加
點擊按鈕圖片切換
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function change(){
//獲取id唯一的標簽
var img = document.getElementById("imgs");
//更換路徑
img.src = 'img/2.jpg';
}
</script>
</head>
<body>
<img id="imgs" src="img/1.jpg" />
<p></p>
<button onclick="change()">改變圖片</button>
</body>
</html>