Node.childElementCount
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.childElementCount
предназначено только для чтения и возвращает число дочерних элементов узла.
Синтаксис
var elCount = Node.childElementCount;
elCount
- целое число, количество дочерних элементов узла Node.Node
- объект, представляющий собойDocument
,DocumentFragment
илиElement
.
Предупреждение:
А наш добрый друг Internet Explorer в 6, 7 и 8 версиях ошибочно считает элементами комментарии в HTML-коде (Comment
).
Пример
js
var foo = document.getElementById("foo");
if (foo.childElementCount > 0) {
// здесь нужный код..
}
Спецификации
Specification |
---|
DOM # dom-parentnode-childelementcount |
Совместимость с браузерами
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
childElementCount |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.