Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript检查对象是否实现HtmlanchoreElement接口_Javascript_Dom_Interface_Anchor - Fatal编程技术网

javascript检查对象是否实现HtmlanchoreElement接口

javascript检查对象是否实现HtmlanchoreElement接口,javascript,dom,interface,anchor,Javascript,Dom,Interface,Anchor,是否有javascript方法来确定对象是否实现了“HtmlanchoreElement”接口?当我执行typeOf(someVariable)时,它返回'object'。我是否可以进一步验证该类型是否实现了“HtmlanchoreElement”接口?看起来很简单,但我找不到任何例子。任何帮助或示例代码都将不胜感激。谢谢 您可以使用运算符 例如: var a = document.links[0]; alert(a instanceof HTMLAnchorElement); // true

是否有javascript方法来确定对象是否实现了“HtmlanchoreElement”接口?当我执行
typeOf(someVariable)
时,它返回
'object'
。我是否可以进一步验证该类型是否实现了“HtmlanchoreElement”接口?看起来很简单,但我找不到任何例子。任何帮助或示例代码都将不胜感激。谢谢

您可以使用运算符

例如:

var a = document.links[0];
alert(a instanceof HTMLAnchorElement); // true if there's a link in the document

请注意,IE7-没有定义
htmlanchoreElement
对象。作为备用方法,您可以检查假定元素的
标记名
节点名
属性。

lol是的,我去吃午饭时想到了这一点。有时候我们只需要休息一下。非常感谢您的回复。