Skip to content
Advertisement

How to prevent TypeError: e.target.getAttribute is not a function? [closed]

What I’m trying to do is the inner code (result) will only work when there’s an attribute of Validity. But since my target doesn’t have an attribute of Validity, I want to prevent the inner code to run by having an if checking.

What can I do to check/prevent the error of TypeError: e.target.getAttribute is not a function?

enter image description here

Advertisement

Answer

use optional chaining or hasOwnProperty() method

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement