Having trouble retrieving the correct CSS value for a background using a spectrum.js color picker. No matter which color is chosen, rgba(0,0,0,0)
is always selected. Strangely enough, when checking the background in the console, it shows up correctly in the DOM.
Any insights on why this might be failing?
<div class="container" id="outside-preview">
<div class="container" id="inside-preview">
<div id="image-square"></div>
</div>
</div>
$(".colorpicker").spectrum({
color: "#FFF",
showInput: true,
className: "full-spectrum",
showInitial: true,
showPalette: true,
showSelectionPalette: true,
maxSelectionSize: 10,
preferredFormat: "hex",
localStorageKey: "spectrum.demo",
change: function(color) {
var eq = $(this).index('.colorpicker');
$('.container').eq(eq).css('background-color', color.toHexString())
}
});
var color = $( "#outside-preview" ).css( "background-color" );
$("#result").html("That div is " + color + "");