Hooshkar
Hooshkar

Reputation: 19

How to change the background or a color of DIV using jQuery colorpicker?

can you please help, i am using this colorpicker here: http://www.eyecon.ro/colorpicker/

and i don't know how to use it, for example if i would like to change the site background color, or a color of Div element, or the color of text how it can be done?

here is the live example... http://pastehtml.com/view/1e78noi.html

for example how would like to change background color, and the color of slider-bg DIV and the color of text DIV.

Please use this site: pastehtml.com to purplish your Live and working html code for showing to me. and copy the sources URL scripts from my source file.

Thanks

Upvotes: 0

Views: 3263

Answers (1)

Richard
Richard

Reputation: 1289

you'll need to use the onchange event the colorpicker provides:

$('#colorSelector').ColorPicker({
    color: '#0000ff',
    onShow: function (colpkr) {
        $(colpkr).fadeIn(500);
        return false;
    },
    onHide: function (colpkr) {
        $(colpkr).fadeOut(500);
        return false;
    },
    onChange: function (hsb, hex, rgb) {
       //this is what you need
       $(".text").css("color", "#" + hex);
    }
});

working sample:

http://jsfiddle.net/r9ZeA/

Upvotes: 1

Related Questions