cyprian cyprian - 1 year ago 60
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


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.