@laserware/dominator
    Preparing search index...

    Function elementExists

    • Checks if the specified target exists in the DOM.

      Parameters

      • target: undefined | null | Target

        Element, EventTarget, or CSS selector.

      Returns boolean

      true if the specified target exists.

      We allow null or undefined as well because a null or undefined element technically doesn't exist.

      HTML

      <ul>
      <li id="item-1">Item 1</li>
      <li id="item-2">Item 2</li>
      </ul>

      Code

      elementExists("#item-1");
      // true

      elementExists(findElement("#item-1"));
      // true

      elementExists("#item-3");
      // false