• 跳至主要内容
  • 跳至搜索
  • 跳至选择语言
MDN Web Docs - MDN 文档
  • 参考
    • 概述 / Web 技术

      面向开发者的 Web 技术参考

    • HTML

      网页内容结构

    • CSS

      用于描述文档样式的代码

    • JavaScript

      通用脚本语言

    • HTTP

      传输 Web 资源的协议

    • Web API

      构建 Web 应用程序的接口

    • Web 扩展

      开发 Web 浏览器扩展

    • Web 技术

      面向开发者的 Web 技术参考

  • 指南
    • 概述 / MDN 学习区域

      学习 Web 开发

    • MDN 学习区域

      学习 Web 开发

    • HTML

      学习使用 HTML 构建网页内容

    • CSS

      学习使用 CSS 样式化内容

    • JavaScript

      学习在浏览器中运行脚本

    • 无障碍访问

      学习使 Web 对所有人开放

  • 加
    • 概述

      定制化的 MDN 体验

    • AI 帮助

      获取实时帮助和支持

    • 更新

      一览所有浏览器兼容性更新

    • 文档

      了解如何使用 MDN Plus

    • 常见问题

      关于 MDN Plus 的常见问题

  • 课程
  • 博客
    • 游乐场

      编写、测试和分享你的代码

    • 新
      HTTP 观察站

      免费扫描网站

    • AI 帮助

      获取实时帮助和支持

  • 登录
  • 免费注册
  1. 参考
  2. Web API
  3. 元素
  4. childElementCount
    • 西班牙语
    • 法语
    • 日语
    • 韩语
    • 葡萄牙语 (巴西)
    • 俄语
    • 中文 (简体)

本文档

  • 示例
  • 规范
  • 浏览器兼容性
  • 另请参阅
  1. 文档对象模型
  2. 元素
  3. 实例属性
    1. ariaAtomic
    2. ariaAutoComplete
    3. ariaBrailleLabel
    4. ariaBrailleRoleDescription
    5. ariaBusy
    6. ariaChecked
    7. ariaColCount
    8. ariaColIndex
    9. ariaColIndexText
    10. ariaColSpan
    11. ariaCurrent
    12. ariaDescription
    13. ariaDisabled
    14. ariaExpanded
    15. ariaHasPopup
    16. ariaHidden
    17. ariaKeyShortcuts
    18. ariaLabel
    19. ariaLevel
    20. ariaLive
    21. ariaModal
    22. ariaMultiLine
    23. ariaMultiSelectable
    24. ariaOrientation
    25. ariaPlaceholder
    26. ariaPosInSet
    27. ariaPressed
    28. ariaReadOnly
    29. ariaRelevant 非标准
    30. ariaRequired
    31. ariaRoleDescription
    32. ariaRowCount
    33. ariaRowIndex
    34. ariaRowIndexText
    35. ariaRowSpan
    36. ariaSelected
    37. ariaSetSize
    38. ariaSort
    39. ariaValueMax
    40. ariaValueMin
    41. ariaValueNow
    42. ariaValueText
    43. assignedSlot
    44. attributes
    45. childElementCount
    46. children
    47. classList
    48. className
    49. clientHeight
    50. clientLeft
    51. clientTop
    52. clientWidth
    53. currentCSSZoom
    54. elementTiming 实验性
    55. firstElementChild
    56. id
    57. innerHTML
    58. lastElementChild
    59. localName
    60. namespaceURI
    61. nextElementSibling
    62. outerHTML
    63. part
    64. prefix
    65. previousElementSibling
    66. scrollHeight
    67. scrollLeft
    68. scrollLeftMax 非标准
    69. scrollTop
    70. scrollTopMax 非标准
    71. scrollWidth
    72. shadowRoot
    73. slot
    74. tagName
  4. 实例方法
    1. after()
    2. animate()
    3. append()
    4. attachShadow()
    5. before()
    6. checkVisibility()
    7. closest()
    8. computedStyleMap()
    9. getAnimations()
    10. getAttribute()
    11. getAttributeNames()
    12. getAttributeNode()
    13. getAttributeNodeNS()
    14. getAttributeNS()
    15. getBoundingClientRect()
    16. getClientRects()
    17. getElementsByClassName()
    18. getElementsByTagName()
    19. getElementsByTagNameNS()
    20. getHTML()
    21. hasAttribute()
    22. hasAttributeNS()
    23. hasAttributes()
    24. hasPointerCapture()
    25. insertAdjacentElement()
    26. insertAdjacentHTML()
    27. insertAdjacentText()
    28. matches()
    29. prepend()
    30. querySelector()
    31. querySelectorAll()
    32. releasePointerCapture()
    33. remove()
    34. removeAttribute()
    35. removeAttributeNode()
    36. removeAttributeNS()
    37. replaceChildren()
    38. replaceWith()
    39. requestFullscreen()
    40. requestPointerLock()
    41. scroll()
    42. scrollBy()
    43. scrollIntoView()
    44. scrollIntoViewIfNeeded() 非标准
    45. scrollTo()
    46. setAttribute()
    47. setAttributeNode()
    48. setAttributeNodeNS()
    49. setAttributeNS()
    50. setCapture() 非标准 已弃用
    51. setHTMLUnsafe()
    52. setPointerCapture()
    53. toggleAttribute()
  5. 事件
    1. afterscriptexecute 非标准
    2. animationcancel
    3. animationend
    4. animationiteration
    5. animationstart
    6. auxclick
    7. beforeinput
    8. beforematch 实验性
    9. beforescriptexecute 非标准
    10. beforexrselect 实验性
    11. blur
    12. click
    13. compositionend
    14. compositionstart
    15. compositionupdate
    16. contentvisibilityautostatechange
    17. contextmenu
    18. copy
    19. cut
    20. dblclick
    21. DOMActivate 已弃用
    22. DOMMouseScroll 非标准 已弃用
    23. focus
    24. focusin
    25. focusout
    26. fullscreenchange
    27. fullscreenerror
    28. gesturechange 非标准
    29. gestureend 非标准
    30. gesturestart 非标准
    31. gotpointercapture
    32. input
    33. keydown
    34. keypress 已弃用
    35. keyup
    36. lostpointercapture
    37. mousedown
    38. mouseenter
    39. mouseleave
    40. mousemove
    41. mouseout
    42. mouseover
    43. mouseup
    44. mousewheel 非标准 已弃用
    45. MozMousePixelScroll 非标准 已弃用
    46. paste
    47. pointercancel
    48. pointerdown
    49. pointerenter
    50. pointerleave
    51. pointermove
    52. pointerout
    53. pointerover
    54. pointerrawupdate 实验性
    55. pointerup
    56. scroll
    57. scrollend
    58. securitypolicyviolation
    59. touchcancel
    60. touchend
    61. touchmove
    62. touchstart
    63. transitioncancel
    64. transitionend
    65. transitionrun
    66. transitionstart
    67. webkitmouseforcechanged 非标准
    68. webkitmouseforcedown 非标准
    69. webkitmouseforceup 非标准
    70. webkitmouseforcewillbegin 非标准
    71. wheel
  6. 继承
    1. 节点
    2. EventTarget
  7. DOM 相关页面
    1. AbortController
    2. AbortSignal
    3. AbstractRange
    4. Attr
    5. CDATASection
    6. CharacterData
    7. Comment
    8. CustomEvent
    9. DOMError 已弃用
    10. DOMException
    11. DOMImplementation
    12. DOMParser
    13. DOMPoint
    14. DOMPointReadOnly
    15. DOMRect
    16. DOMTokenList
    17. Document
    18. DocumentFragment
    19. DocumentType
    20. 事件
    21. EventTarget
    22. HTMLCollection
    23. MutationObserver
    24. MutationRecord
    25. NamedNodeMap
    26. 节点
    27. NodeIterator
    28. NodeList
    29. ProcessingInstruction
    30. Range
    31. StaticRange
    32. Text
    33. TextDecoder
    34. TextEncoder
    35. TimeRanges
    36. TreeWalker
    37. XMLDocument

本文档

  • 示例
  • 规范
  • 浏览器兼容性
  • 另请参阅

元素:childElementCount 属性

Element.childElementCount 只读属性返回此元素的子元素数量。

示例

js
let sidebar = document.getElementById("sidebar");
if (sidebar.childElementCount > 0) {
  // Do something
}

规范

规范
DOM 标准
# dom-parentnode-childelementcount

浏览器兼容性

BCD 表格仅在启用 JavaScript 的浏览器中加载。

另请参阅

  • Document.childElementCount
  • DocumentFragment.childElementCount

帮助改进 MDN

了解如何贡献.

此页面最后修改于 2023年4月7日 由 MDN 贡献者.

在 GitHub 上查看此页面 • 报告此内容的问题
MDN logo - MDN 文档

您构建更美好互联网的蓝图。

  • Mastodon 上的 MDN
  • X 上的 MDN(以前称为 Twitter)
  • GitHub 上的 MDN
  • MDN 博客 RSS Feed

MDN

  • 关于
  • 博客
  • 职业生涯
  • 与我们合作广告

支持

  • 产品帮助
  • 报告问题

我们的社区

  • MDN 社区
  • MDN 论坛
  • MDN 聊天

开发者

  • Web 技术
  • 学习 Web 开发
  • MDN Plus
  • Hacks 博客
Mozilla logo - MDN 文档
  • 网站隐私声明
  • Cookie
  • 法律
  • 社区参与指南

访问 Mozilla 公司的 非营利母公司, Mozilla 基金会.
此内容的部分内容为 ©1998–2024由各个 mozilla.org 贡献者提供。内容根据 知识共享许可证提供

.