ttmt — 2014-06-29T04:51:51-04:00 — #1
I have a jsfiddle here: http://jsfiddle.net/ecWT5/
It's 3 different colored blocks.
I want to show the color of the block on the block.
The blocks all have a class name.
So If I get the color using the class name it shows the same color on all blocks
Is it possible to use something like $(this) block with a class name to get the color of this block.
strider64 — 2014-06-29T08:39:35-04:00 — #2
Don't know exactly what you're look for, but maybe something like this? http://jsfiddle.net/Strider64/4zQQu/
rubble — 2014-06-29T08:45:00-04:00 — #3
The way I read the post @Strider64; is he wants the colour in text on the block.
It looks like your code opens a window with the colour code when clicked - the op wants the colour code written on the block without having to click anything?
ttmt — 2014-06-29T08:54:49-04:00 — #4
Yes I want to display the colour of the block in rgb or hex.
But thats not really the question here.
Each block has the same class name.
If I use the class name in jQuery it gives me the same colour for each block
var color = $('.my_Box').css('backgroundColor');
Is there a way in jQuery to get the different colour in each block using a class name.
strider64 — 2014-06-29T09:02:07-04:00 — #5
Something like this? http://jsfiddle.net/Strider64/TZ9AL/1/
Yes there is, by using each (basically a loop statement) on the class and grabbing the css background-color for each class that is name my_Box.
ttmt — 2014-06-29T09:13:46-04:00 — #6
valjas — 2014-06-29T23:54:17-04:00 — #7
A simpler version if you're not looking for RGB to Hex conversion: http://jsfiddle.net/ecWT5/4/