筆記: window對象 ● window.innerHeight - 瀏覽器窗口的內部高度 ● window.innerWidth - 瀏覽器窗口的內部寬度 ● window.open() - 打開新窗口 ● window.close() - 關閉當前窗口 navigator對象 navigator.appName // web瀏覽器全稱 navigator.appVersion // web瀏覽器廠商和版本的詳細字符串 navigator.userAgent // 客戶端絕大部分信息 navigator.platform // 瀏覽器運行所在的操做系統 screen對象 screen.availWiddth // 可用的屏幕寬度 screen.avaliWidth // 可用的屏幕高度 history對象 window.history對象包含瀏覽器歷史 history.forward() //前進一頁 history.back() // 後退一頁 location對象 window.location 對象用於獲取當前頁面的地址URL,並把瀏覽器從新定向到新的頁面。 location.herf // 獲取URl location.herf="URL" // 跳轉到指定頁面 location.reload() // 從新加載頁面 計時相關: setTimeout() // var t = setTimeout("js語句",毫秒) clearTimeout() // clearTimeout(setTimeout_variable) setInterval() clearInterval() DOM 查找標籤: 直接查找 document.getElementById // 根據Id獲取一個標籤 document.getElementByClassName // 根據class屬性獲取 document.getElementByTagName // 根據標籤名稱獲取標籤合集 間接查找 parentElement // 父節點標籤元素 children // 全部子標籤 firstElementChild // 第一個子標籤元素 lastElementChild // 最後一個子元素元素 nextElementSibling // 下一個兄弟標籤元素 previousElementSibling // 上一個兄弟標籤元素 節點操做: 建立節點:document.createElement(「標籤名」) 添加節點:追加一個子節點(做爲最後的子節點)somenode.appendChild(newnode) 把新增的節點放到某個節點的前邊:somenode.insertBefore(newnode,某個節點) 刪除節點:獲取要刪除的元素,經過父元素調用該方法刪除 somenode.removeChild("要刪除的節點") 替換節點:some.node.replateChild(newnode,某個節點) 屬性節點: innerText innerHTML setAttribute getAttribute removeAttribute 自帶屬性能夠直接.屬性名獲取和設置 獲取值操做: elementNode.value 適用於 input select textarea calss的操做: classList.remove(cls) 刪除指定類 classList.add(cls) 添加類 classList.contains(cls) 存在返回true,不然返回false calssList.toggle(cls) 存在就刪除,不然添加 指定css操做: obj.style. 對於沒有中劃線的css屬性通常直接使用style.屬性名便可 對於有中劃線的css屬性通常將中劃線後的第一個字母換成大寫 事件: HTML中的事件出發瀏覽器的action onclick // 點擊 ondblclick // 雙擊 onfocus // 得到焦點 onblur // 失去焦點 onchange // 域的內容被改變 onkeydown // 鍵盤按鍵被按下 onkeypress // 鍵盤按鍵被按下而且鬆開 onkeyup // 鍵盤按鍵被鬆開 onload // 完成加載 onmousedown // 鼠標按下 onmousemove // 鼠標被移動 onmouseout // 鼠標從某元素移開 onmouseover // 鼠標在某元素之上 onselect // 文本框中的元素被選中 onsubmit // 確認按鈕被點擊