I mean, how can I find which of two elements belongs to a node nearest to ‘document’ or ‘window’? which is higher in hierarchy?
EDIT
this gets the job done:
function gerarchia(elem) {
var i=0;
while (elem.parentNode) {
elem = elem.parentNode;
i++;
}
return i;
}
Try
.parents().length, like this: