Becky
Becky

Reputation: 2289

Setting a color from spectrum to another div

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?

Click to see it in a fiddle

Here is the github page

Upvotes: 0

Views: 1130

Answers (1)

empiric
empiric

Reputation: 7878

According to their documentation you can use the change-function for that:

change: function(color) {
    $('.outside-preview').css('background-color',  color.toHexString())
}

Example


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());

Example

Upvotes: 1

Related Questions