It is better to change the title to review, because there are a lot of knowledge points in the book, which is not easy to summarize. I would like to mention it and repeat the Code if I think it is important. To continue (2), delete a node from Dom: nodeparent. removechild (nodetoremove );
In the book, removechild encapsulates two functions:
// Remove a node from the DOM
Function remove (ELEM ){
If (ELEM) ELEM. parentnode. removechild (ELEM );
}
// Clear all child nodes of an element
Function empty (ELEM ){
While (ELEM. firstchild ){
Remove (ELEM. firstchild );
}
}
The Dom part is the end of the review, followed by the event part. It is also a core component of Javascript development. When it comes to events, there is an important concept. Javascript events are divided into two phases: Capturing and bubbling phase, which are called the capture and bubble phases of events.
Here is an example to illustrate the problem:
<Body>
<Div id = "content">
<Ul class = "Links">
<Li>
<A href = "/"> Home </a> // click this link.
</LI>
<Li> <a href = "/about/"> about </a> </LI>
</Ul>
</Div>
</Body>
First, capturing phase: Suppose we have clicked a link and the event trigger sequence is: the click Processing Event of the document --> the click Processing Event of the body -->
The DIV's click Processing Event finally reaches the we clicked, and then enters the bubbling phase. The order is the opposite to capturing phase.
Sometimes we want to cancel event bubbling:
Function stopbubble (e ){
// If the event object is input by default, this is not an IE browser
If (E & E. stoppropagation)
// Supports the W3C standard stoppropagation () method.
E. stoppropagation ();
Else
// Otherwise, we will use IE to cancel event bubbling.
Window. event. cancelbubble = true;
}
We should also pay attention to the default browser behavior during the development process. For example, when the user enters the content in a user form and presses the submit button, if the content of the form is incorrect, an error should be reported to the user and not submitted. Prevent the default behavior of the browser:
Function stopdefault (e ){
// Block default browser behavior (W3C)
If (E & E. preventdefault) E. preventdefault ();
Else window. event. returnvalue = false; // Method Used in IE
Return false;
}
Next, the author describes some principles for developing web pages. For example, if CSS and JavaScript are removed, check whether your web pages can be properly navigated and browsed, whether your HTML tag has good semantics, whether CSS and JavaScript are separated from HTML Dom, etc .. I think there is a good book on CSS, "beyond CSS: the essence of web design".