Hi.

Does the jquery parent() traversing the same as the DOM 'parentNode' ?

I ask because i get different results while traversing some Nodes with DOM Style and jquery approach.

jquery Style:
$(elem).parent().parent().attr('for');

(Prototype) Helper function with plain DOM Javascript:
function Helper_getAttrParentNode (attr, elem, level)
{
        for (var a = elem; level > 0; level--) {
                a = a.parentNode;
        }
        return a.getAttribute(attr);
}

Usage:
Helper.getAttrParentNode('for', elem, 2)

Which both of them should do the same thing. Or do i miss something here?

Thanks in advance.

bye
Olaf

--
Olaf Gleba : creatics media.systems
Tel. +49 (0)221 170 67 224 : Fax. +49 (0)221 170 67 225
[EMAIL PROTECTED] : http://www.creatics.de
PGP-Key http://www.creatics.de/keys/





Reply via email to