• Skip to main content
  • Skip to search
  • Skip to select language
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. Web APIs
  3. Element
  4. Element.childElementCount
  • Change language

Table of contents

  • Examples
  • Specifications
  • Browser compatibility
  • See also

Element.childElementCount

The Element.childElementCount read-only property returns the number of child elements of this element.

Examples

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

Specifications

Specification
DOM Standard
# dom-parentnode-childelementcount

Browser compatibility

BCD tables only load in the browser

See also

  • Document.childElementCount
  • DocumentFragment.childElementCount

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Mar 29, 2022, by MDN contributors

Change your language

Related Topics

  1. Document Object Model
  2. Element
  3. Properties
    1. ariaAtomic
    2. ariaAutoComplete
    3. ariaBusy
    4. ariaChecked
    5. ariaColCount
    6. ariaColIndex
    7. ariaColIndexText
    8. ariaColSpan
    9. ariaCurrent
    10. ariaDescription
    11. ariaDisabled
    12. ariaExpanded
    13. ariaHasPopup
    14. ariaHidden
    15. ariaKeyShortcuts
    16. ariaLabel
    17. ariaLevel
    18. ariaLive
    19. ariaModal
    20. ariaMultiline
    21. ariaMultiSelectable
    22. ariaOrientation
    23. ariaPlaceholder
    24. ariaPosInSet
    25. ariaPressed
    26. ariaReadOnly
    27. ariaRelevant
    28. ariaRequired
    29. ariaRoleDescription
    30. ariaRowCount
    31. ariaRowIndex
    32. ariaRowIndexText
    33. ariaRowSpan
    34. ariaSelected
    35. ariaSetSize
    36. ariaSort
    37. ariaValueMax
    38. ariaValueMin
    39. ariaValueNow
    40. ariaValueText
    41. assignedSlot
    42. attributes
    43. childElementCount
    44. children
    45. classList
    46. className
    47. clientHeight
    48. clientLeft
    49. clientTop
    50. clientWidth
    51. firstElementChild
    52. id
    53. innerHTML
    54. lastElementChild
    55. localName
    56. namespaceURI
    57. nextElementSibling
    58. openOrClosedShadowRoot
    59. outerHTML
    60. part
    61. prefix
    62. previousElementSibling
    63. scrollHeight
    64. scrollLeft
    65. scrollLeftMax
    66. scrollTop
    67. scrollTopMax
    68. scrollWidth
    69. shadowRoot
    70. slot
    71. tagName
  4. Methods
    1. after()
    2. animate()
    3. append()
    4. attachShadow()
    5. before()
    6. closest()
    7. computedStyleMap()
    8. createShadowRoot()
    9. getAnimations()
    10. getAttribute()
    11. getAttributeNames()
    12. getAttributeNode()
    13. getAttributeNodeNS()
    14. getAttributeNS()
    15. getBoundingClientRect()
    16. getClientRects()
    17. getElementsByClassName()
    18. getElementsByTagName()
    19. getElementsByTagNameNS()
    20. hasAttribute()
    21. hasAttributeNS()
    22. hasAttributes()
    23. hasPointerCapture()
    24. insertAdjacentElement()
    25. insertAdjacentHTML()
    26. insertAdjacentText()
    27. matches()
    28. msZoomTo()
    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. setHTML()
    52. setPointerCapture()
    53. toggleAttribute()
  5. Events
    1. afterscriptexecute
    2. auxclick
    3. blur
    4. click
    5. compositionend
    6. compositionstart
    7. compositionupdate
    8. contextmenu
    9. copy
    10. cut
    11. dblclick
    12. DOMActivate
    13. DOMMouseScroll
    14. error
    15. focus
    16. focusin
    17. focusout
    18. fullscreenchange
    19. fullscreenerror
    20. gesturechange
    21. gestureend
    22. gesturestart
    23. keydown
    24. keypress
    25. keyup
    26. mousedown
    27. mouseenter
    28. mouseleave
    29. mousemove
    30. mouseout
    31. mouseover
    32. mouseup
    33. mousewheel
    34. MozMousePixelScroll
    35. msContentZoom
    36. MSGestureChange
    37. MSGestureEnd
    38. MSGestureHold
    39. MSGestureStart
    40. MSGestureTap
    41. MSInertiaStart
    42. MSManipulationStateChanged
    43. paste
    44. scroll
    45. securitypolicyviolation
    46. select
    47. show
    48. touchcancel
    49. touchend
    50. touchmove
    51. touchstart
    52. webkitmouseforcechanged
    53. webkitmouseforcedown
    54. webkitmouseforceup
    55. webkitmouseforcewillbegin
    56. wheel
  6. Inheritance:
    1. Node
    2. EventTarget
  7. Related pages for DOM
    1. AbortController
    2. AbortSignal
    3. AbstractRange
    4. Attr
    5. ByteString
    6. CDATASection
    7. CharacterData
    8. Comment
    9. CustomEvent
    10. DOMError
    11. DOMException
    12. DOMImplementation
    13. DOMParser
    14. DOMPoint
    15. DOMPointReadOnly
    16. DOMRect
    17. DOMTimeStamp
    18. DOMTokenList
    19. Document
    20. DocumentFragment
    21. DocumentType
    22. Event
    23. EventTarget
    24. HTMLCollection
    25. MutationObserver
    26. NamedNodeMap
    27. Node
    28. NodeFilter
    29. NodeIterator
    30. NodeList
    31. ProcessingInstruction
    32. Range
    33. StaticRange
    34. Text
    35. TextDecoder
    36. TextEncoder
    37. TimeRanges
    38. TreeWalker
    39. XMLDocument
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2022 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies