How to run Jquery constructor from own function?
Posted
by
Invidian
on Stack Overflow
See other posts from Stack Overflow
or by Invidian
Published on 2013-11-09T20:24:32Z
Indexed on
2013/11/09
21:54 UTC
Read the original article
Hit count: 278
I need to create a function which will returning jQuery.Color object and i have no idea how to do it. Here is code example
function newcolor () { var obj = new $.Color( 'rgb(0,0,0)' ); return obj;}
var foo = newcolor();
foo.red();
Edit:
My full code:
function my (element,a,b,c){ //class my
this.target = $(elem);
this.new_color = function (a,b,c) { return new $.Color( 'rgb('+a+','+b+','+c+')'); }
this.base_color = new_color (a,b,c);
this.colorize = function () ( this.target.css({ background-color: new_color });
}
var div = new My($('foo'),0,0,0);
div.new_color(255,255,255);
div.colorize();
My goal is to create class which can hold jquery element and operate on it. Now I'm stuck on returning $.Color().
© Stack Overflow or respective owner