Node.parentElement

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Свойство Node.parentElement только для чтения, возвращает родителя узла DOM Element, или null если узел не имеет родителя, или его родитель не DOM Element.

Синтаксис

parentElement = node.parentElement

parentElement это родительский элемент текущего узла. Это всегда объект DOM Element, или null.

Пример

js
if (node.parentElement) {
  node.parentElement.style.color = "red";
}

Спецификации

Specification
DOM
# ref-for-dom-node-parentelement①

Совместимость с браузерами

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
parentElement

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

Смотрите также