javascript - How to find which element stands higher in the DOM hierarchy? -



javascript - How to find which element stands higher in the DOM hierarchy? -

i mean, how can find of 2 elements belongs node nearest 'document' or 'window'? higher in hierarchy?

edit gets job done:

function gerarchia(elem) { var i=0; while (elem.parentnode) { elem = elem.parentnode; i++; } homecoming i; }

try .parents().length, this:

if ( $(element1).parents().length > $(element2).parents().length ) { // lower } else { // higher }

javascript dom hierarchy

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -