• Checks if the target matches the specified tagName. If the target doesn't exist or is invalid, returns false.

    Type Parameters

    • TN extends TagName

      Tag name of element representation of specified target.

    Parameters

    • target: null | Target

      Element, EventTarget, or CSS selector.

    • tagName: TN

      Tag name to check for (e.g. div, span, etc.).

    Returns target is ElementOf<TN>

    true if the target is of type tagName.

    You can't UPPERCASE the tagName without getting a type error. That's because this function converts it to lowercase before checking.