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
?
Advertisement
Answer
use optional chaining or hasOwnProperty()
method