• Converts rgba text representation of color in hex

    Returns

    hex color view, NaN - for transparent color

    Example

    var p = document.createElement('p');
    p.style.color = '#ffffff';
    console.log(p.getAttribute('style')); // color: rgb(255, 255, 255);
    console.log(colorTohex(p.style.color)); // #ffffff

    Parameters

    • color: string

      string like rgba(red, green, blue, alpha) or rgb(red, green, blue)

    Returns string | false

Jodit PRO

If you like Jodit - try Jodit PRO