HarryIsBack
HarryIsBack

Reputation: 40

ColorPicker bind color

I have a problem and i dont know how to deal with it: i have a ColorPicker and a button to reset back to default color, look like this:

<div id="headercolor2"></div>
<button type="button" onlcick="resetColor()">Reset</button>

<script>
 $('#headercolor2').ColorPicker({
            color: '#000000',
            onShow: function (colpkr) {
                $(colpkr).fadeIn(500);
                return false;
            },
            onHide: function (colpkr) {
                $(colpkr).fadeOut(500);
                return false;
            },
            onChange: function (hsb, hex, rgb) 
            }
        });
</script>

I want to reset back to my default color if i click on the reset button. But i dont know how to do it. I have searched for the document but i could not find it. What should i do inside resetColor()? thank you.

Upvotes: 0

Views: 79

Answers (1)

Cᴏʀʏ
Cᴏʀʏ

Reputation: 107536

I think you're using the http://www.eyecon.ro/colorpicker/ library. If so, your function should look like:

function resetColor() {
    $('#headercolor2').ColorPickerSetColor('#ff0000');
}

There was an example of this right on the "Implement" tab on the site above. The documentation states that the default color is #ff0000.

Upvotes: 1

Related Questions