Becky Becky - 1 year ago 109
Javascript Question

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 id="inside-preview">


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

Answer Source

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

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download