It returns the previous sibling node, it might be text node
, it might be element node
, it might be null
You can retrieve previous element nodes with .previousElementSibling
which isn't supported in legacy browsers but you can use a function like:
function previousElementSibling( elem ) {
do {
elem = elem.previousSibling;
} while ( elem && elem.nodeType !== 1 );
return elem;
}
previousElementSibling(this)
will result in the input element.