@laserware/dominator
    Preparing search index...

    Function idMatches

    • Checks if the target has the ID property that matches id.

      Note that you can pass an ID string or CSS selector (e.g. #some-id). If your ID starts with # and is not a CSS selector, ensure there are two # prefixes instead of one.

      Parameters

      • target: null | Target

        Element, EventTarget, or CSS selector.

      • id: string

        ID to check for element.

      Returns boolean

      true if the target has the specified id.

      InvalidElementError if the specified target wasn't found.

      HTML

      <div class="example" id="no-hash">Example</div>
      <div class="example" id="#hash">Example</div>

      Code

      const [noHash, hasHash] = findAllElements(".example");

      idMatches(noHash, "no-hash");
      // true

      idMatches(hasHash, "#hash");
      // false

      idMatches(hasHash, "##hash");
      // true