javascript 检查对象是否实现 HTMLAnchorElement 接口
有没有一种 JavaScript 方法可以确定对象是否实现“HTMLAnchorElement”接口?当我执行 typeOf(someVariable)
时,它返回 'object'
。我可以更进一步并验证该类型是否实现了“HTMLAnchorElement”接口?看起来很简单,但我找不到任何例子。任何帮助或示例代码将不胜感激。谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
instanceof
运算符。示例:
请注意,IE7- 未定义
HTMLAnchorElement
对象。作为后备方案,您可以检查假定元素的tagName
或nodeName
属性。You can use the
instanceof
operator.Example:
Note that IE7- doesn't define the
HTMLAnchorElement
object. As a fallback, you can check for thetagName
ornodeName
property of a supposed element.