Đang chuẩn bị liên kết để tải về tài liệu:
THE BOOK OF JAVASCRIPT, 2ND EDITION p6

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Thao tác với một trang Sử dụng DOM Như đã đề cập trước đó, bạn có thể làm hầu hết những điều được mô tả trong phần này với việc sử dụng sáng tạo của innerHTML. Tuy nhiên, đôi khi đối phó với các chuỗi phức tạp cần thiết để có được innerHTML là những gì bạn muốn có thể được khó khăn. Trong những trường hợp này, các kỹ thuật DOM là rất hữu ích. Khi chúng tôi nhận được các chương nói về. | The word true inside the cloneNode method means that you want to clone the node and all its children. In this case it would be the table and all the contents of the table. If for some reason you didn t want to make a copy of the children you d put false there. Once you ve made your changes you can replace the original table with the new one using the replaceNode method. Like insertBefore and removeChild this method is called by the parent of the nodes to be replaced. Given the myTable and cloneTable variables defined above you could do this var tableParent myTable.parentNode tableParent.replaceChild cloneTable myTable Manipulating a Page Using the DOM As mentioned earlier you could do most of the things described in this section with creative use of innerHTML. However sometimes dealing with the complex strings needed to get innerHTML to be what you want can be difficult. In these cases the DOM techniques are very helpful. When we get to the chapters on Ajax you ll see even more applications of the DOM manipulation techniques. Fancy Event Handling Dynamic web pages call for dynamic reactions to user actions. We ve discussed how to write JavaScript that reacts when users click links buttons and form elements. Now it s time to learn about more complicated event handling how to accurately read the keyboard and the mouse. The event Object Whenever an event occurs an event object is generated. The nature of this object depends on the event which generated it. To access the event object simply pass the keyword event to whichever function is handling the event a href onClick handleClick event return false Click me a . The event object is most frequently accessed when you want to know which key a user has pressed or precisely where the mouse is. Keyboard Events There are two main keyboard event handlers the functions of which are pretty obvious onKeyDown and onKeyUp. Triggering either of these event handlers creates an event object that stores which key has been pressed or

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.