function prev( node ){
do {
elem = elem.previousSibling;
} while( elem && elem.nodeType != 1 );
return elem;
}
In this function we are looking for previous node to a given node. Got this piece of code from John Resig work. This works perfectly I would like have deep understanding of this specifically why he checks elem.nodeType != 1
Somebody pls explain.
nodeType == 1is an element node.So this code selects first previous node that is an element.
Full list of node types you can find here.