Macklin
07-24-2009, 09:12 PM
New to javascript, so this may be an obvious question.
When I use
document.getElementByID("someElement").style.color
it apparently returns a string formatted thus: 'rgb(0, 0, 0)'. This seems very clunky to me. Is there a way to get the red, green, and blue values without resorting to some monstrosity like
var color = document.getElementByID("someElement").style.color;
var red = color.split('(')[1].split(',')[0];
etc.
I've searched for a while now, but I can't seem to hit the jackpot for a simple guide on how to manipulate colors. I found a comprehensible library for handling colors that could get the job done, but it seems like overkill for what I have in mind.
As an aside, do you have a guide you would recommend for introductory javascript? I've found several that answer one or two of my questions, but I haven't found a reference that can answer more than roughly a quarter of my questions.
Thank you for reading.
When I use
document.getElementByID("someElement").style.color
it apparently returns a string formatted thus: 'rgb(0, 0, 0)'. This seems very clunky to me. Is there a way to get the red, green, and blue values without resorting to some monstrosity like
var color = document.getElementByID("someElement").style.color;
var red = color.split('(')[1].split(',')[0];
etc.
I've searched for a while now, but I can't seem to hit the jackpot for a simple guide on how to manipulate colors. I found a comprehensible library for handling colors that could get the job done, but it seems like overkill for what I have in mind.
As an aside, do you have a guide you would recommend for introductory javascript? I've found several that answer one or two of my questions, but I haven't found a reference that can answer more than roughly a quarter of my questions.
Thank you for reading.