Color Spectrum color gets color with transparency

I use the jQuery Spectrum plugin to select a color:

$('#backgroundColorPicker').spectrum({
    color: '#000',
    showAlpha: true,
    move: function(color){
        $('#result').css('background-color',color.toHexString());
    }
});

See this code in action: http://jsfiddle.net/UkmXM/1/ .

As you can see, I set showAlphato trueto enable a transparent background. However, I do not get a transparent background.

+8
source share
2 answers

The hexadecimal string does not support transparency. Use color.toRgbString(): http://jsfiddle.net/UkmXM/2/ instead

$('#backgroundColorPicker').spectrum({
    color: '#000',
    showAlpha: true,
    move: function(color){
        $('#result').css('background-color',color.toRgbString());
    }
});
+16
source

I found this in TinyColor docs :toHex8String

0
source

All Articles