UMD Web Utilities Library
    Preparing search index...

    Function extractIconElement

    • Extracts and prepares an icon element (SVG or IMG) from a container

      Searches for SVG or IMG elements within a container and applies custom color if specified. Returns null if no icon is found.

      Parameters

      • element: { element: HTMLElement }

        The container element to search

      Returns HTMLImageElement | SVGSVGElement | null

      The icon element (SVG or IMG) or null if not found

      const container = document.createElement('div');
      const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
      svg.setAttribute('color', '#ff0000');
      container.appendChild(svg);

      const icon = extractIconElement({ element: container });
      // Returns the SVG element with color applied