此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Node.isSameNode

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2016年8月⁩.

概述

判断两个节点是否是相同的节点,即指向同一个对象。

警告: 该方法已在 DOM level 4 中被废弃,最近的浏览器版本 (Gecko 10.0) 已经删除了这个方法。也就是说,不要再使用 node1.isSameNode(node2) 而使用 node1 === node2 或者 node1 == node2 来代替。

语法

js
var isSameNode = node.isSameNode(other);
  • other 是要和 node 判断相同性的另一个节点。

规范