cyprian cyprian - 2 years ago 90
Javascript Question

Undefined value after using .parentElement

I don't know why but when I use

I get undefined but in Chrome debbuger I see that there is form, where is the bug?

$('.ZamIlosc').each(function () {
var tdstan = $(this).parentElement;
// ...forward code

Answer Source

Either use this.parentElement (an attribute of the element) or $(this).parent() (jQuery's function to get the parent element).

By surrounding this with $( ) you're turning it into a jQuery object, which requires the usage of .parent() instead of .parentElement.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download