Original article: http://blog.csdn.net/biologypianoprogram/archive/2009/04/30/4139903.aspx
1: nextsibling attributes
This attribute indicates the next node of the current node (the node after it belongs to the same level as the current node). If it does not have a node of the same level as it later, null is returned.
Note that the execution results of this attribute in different browsers are different. See the following example:
Let's look at an example:
View plaincopy to clipboardprint?
-
-
- "A4" type = "button" onclick = "alert (this. nextsibling ); " value = " D " /> / LI>
- "A5" type = "button" onclick = "alert (this. nextsibling ); " value = " E " /> / LI>
-
-
On the surface of the object structure, div's nextsibling has only two items-two input nodes. But there are actually five items --/N, input,/N, input,/n. This is because the input is used as the tag to create various form input controls, whether it is to generate buttons, checkbox, radio... or other form controls, ie will automatically create a 1-byte white space.
IE will skip the space document nodes generated between nodes (such as line breaks), but Mozilla will not -- FF will regard typographical elements such as space line breaks as node reads. Therefore, in IE, nextsibling is used to read the next node element. In ff, you need to write nextsibling. nextsibling.
Opera and Safari process nextsibling in the same way as ff.
2: previussibling attributes
This attribute is opposite to the nextsibling attribute. For example, sometagobject. nextsibling. previussibling actually returns the label element, provided that the element must be followed by an element of the same level; otherwise, null is returned.
3: PassNextsibling or Attribute problems of HTML Tag Element objects obtained by previussibling
Generally, nextsibling is used first. nodename to know its label name, or through nextsibling. nodetype to obtain the label type, and then, if the nextsibling. nodename = # text, use nextsibling. nodevalue to obtain its text value; otherwise, you can use nextsibling. other common Tag Element attributes, such as innerhtml, are used to obtain their attributes.