@laserware/dominator
    Preparing search index...

    Function getStyle

    • Attempts to get the specified style property with name key from the specified target. If the value is found, it is coerced to a boolean if "true" or "false", a number if numeric, or the string value if a string. If not found, returns undefined.

      Type Parameters

      • V extends StyleValue = string

        Type of value to return.

      Parameters

      • target: null | Target

        Element, EventTarget, or CSS selector.

      • key: StyleKey

        Name of the style property to get.

      Returns undefined | V

      Value of type T or undefined if not found.

      elements!InvalidElementError if the target could not be found or doesn't have a style property.

      HTML

      <div
      id="example"
      style="display: flex; line-height: 1.5;"
      >...</div>

      Code

      const element = findElement("#example")!;

      getStyle(element, "display");
      // "flex"

      getStyle(element, "lineHeight");
      // 1.5