Reputation: 2289
I am having a difficult time trying to figure out how to set a color I choose from spectrum to another div. My HTML is like this:
<h2>Full Example</h2>
<input type='text' id="full"/>
<div class="outside-preview">
</div>
<div id="inside-preview">
</div>
The input is the spectrum and it changes the small box color. This is all standard to the plugin. I am wanting to set that same color to one of the boxes (inside-preview or outside-preview) as well.
Does anyone see what I have to do?
Upvotes: 0
Views: 1130
Reputation: 7878
According to their documentation you can use the change
-function for that:
change: function(color) {
$('.outside-preview').css('background-color', color.toHexString())
}
To set the backgroundcolor for the corresponding div
with multiple colorpickers you can use something like this:
var eq = $(this).index('.colorpicker');
$('.container').eq(eq).css('background-color', color.toHexString());
Upvotes: 1