-2

使用标签名称和属性就是这样,所以我可以安全地使用 examplehasAttributetagName其他类似方法。

(我的问题是一种积极要求 html 元素的方法,而不是排除所有可能性,如字符串、数字、某种其他对象等)

4

1 回答 1

0

你检查它是否是一个实例HTMLElement

if (varName instanceof HTMLElement){
   // do what you want with the node
}
于 2016-01-24T13:41:18.243 回答