I'm working on a little project where I have multiple multicolored items, and tags within them. Instead of specifying my color for both text and background, I'd like to just get the background color of my parent div and assign it to the color of my text.
My current jQuery looks like this:
$(".infobox").each(function() {
var tagcolor = $(this).closest('.info').css('background');
$(this).css('color',tagcolor);
alert(tagcolor);
});
My HTML is
<div class="info" style="background: #408FCE;">
<div class="infobox">
tags
</div>
</div>
As you can see from my jQuery, I created an alert that will show me the value of the variable "tagcolor", and weirdly it seems to be getting all other unwanted CSS values, even though I specified "Background". I can't figure out what I'm doing wrong, how can I fix this?
EDIT: Did some reseach here;
What is the difference between background and background-color
Apparantly "background" returns a bunch of different stuff.