Is there a javascript way of determining if an object implements the ‘HTMLAnchorElement’ interface? When I do typeOf(someVariable) it returns 'object'. Can I take that a step further and verify the type implements the ‘HTMLAnchorElement’ interface? Seems like it would be simple enough but I can’t find any examples. Any help or sample code would be appreciated. Thanks!
Is there a javascript way of determining if an object implements the ‘HTMLAnchorElement’ interface?
Share
You can use the
instanceofoperator.Example:
Note that IE7- doesn’t define the
HTMLAnchorElementobject. As a fallback, you can check for thetagNameornodeNameproperty of a supposed element.