Edit this page

up.element up.element.isEmpty(element)
JavaScript function

This feature is experimental. Please share your experiences so we know what to keep or change.

Returns whether the given element has no content.

An element is considered to have content if it has either child elements or non-whitespace text.

Examples

These <div> elments are all considered empty:

<div></div>

<div>   </div>

<div attr="text"></div>

These <div> elements are not considered empty:

<div>
  Text
</div>

<div>
  <span>Text</span>
</div>

<div>
  <span></span>
</div>

Parameters

element Element

Return value

boolean

Whether the given element is empty.