I am getting Uncaught TypeError: Cannot read property 'closest' of undefined

Here is my code:

var _self = this;
            var btn = _self.element;

    var parentBlock = _self.element.closest('.new-shipping-address-form').find('form.form');
     var input = parentBlock.find('input[aria-required=true]');

Can you please check my code?

enter image description here

1 Answer 1


The error tells you that _self.element is undefined, you should debug it to see what element refers to and see if you can fix it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.