What would be the easiest way to transform
$(\'#my_element\').css(\'backgroundColor\')
to object like this:
{ r: red_value,
You would do something like:
$.fn.ToRgb = function()
{
if(this.charAt(0) == "#"){this = this.substring(1,7);} //remove the #
return {
R : parseInt(this.substring(0,2) ,16),
G : parseInt(this.substring(2,4) ,16),
B : parseInt(this.substring(4,6) ,16),
}
}
RGB = $('#my_element').css('backgroundColor').ToRgb();
/*
* console.log(rgb) =>
* {
* R: X
* G: X
* B: X
* }
*/
Pretty simple :)