Professional Documents
Culture Documents
Chuong 04 JavaScript
Chuong 04 JavaScript
JAVASCRIPT
Mục đích
http://web.simmons.edu/~grabiner/comm244/weekfou
r/document-tree.html
Node of HTML
Node
Property Event
Inline
Internal
External
Inline JavaScript
<script>
function hello(){
alert(‘Hello’);
}
</script>
External
<header>
<script src=" lam.js“></script>
</header>
function hello(){
lam.js
alert(‘Hello’);
}
Thao tác trên DOM
document.getElementById(“id”)
Thao tác trên DOM
document.getElementsByName(“name”)
document.getElementsByTagName(“ten_the”)
Thao tác trên DOM
document.getElementsByClassName(“class”)
Thao tác trên DOM
document.getAttribute(“ten_attr”)
Thao tác trên DOM
document.setAttribute(“attr_name”,” attr_value”)
Thao tác trên DOM
document.innerHTML = “value”
Thao tác trên DOM
document.style.attr_name = “value”
Thao tác trên DOM
document.createElement(“ten_the”)
Thao tác trên DOM
document.createTextNode(“chuỗi text”)
Thao tác trên DOM
document.appendChild(value)
Thao tác trên DOM
document.insertBefore(para1, para2);
Thao tác trên DOM
document.replaceChild(para1, para2);
Thao tác trên DOM
document.removeChild(para);
Bài tập 01: Kiểm tra tính hợp lệ
Bài tập 02: Thu và mở rộng form
Bài tập 03 : Lấy dữ liệu table xuống form
Xin chân thành cảm ơn !