HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The following code fragment loads "books.xml" into xmlDoc and gets the previous sibling node from the first <author> element
The previousSibling property returns the previous sibling node (the previous node in the same tree level) of the selected element
If there is no such node, this property returns null.
elementNode.previousSibling
Element nodes has a nodeType of 1, so if the previous sibling node is not an element node, it moves to the previous node, and checks if this node is an element node. This continues until the previous sibling node (which must be an element node) is found. This way, the result will be correct in all browsers.
❮ Element Object