问题
I'm trying to create the illusion of transparent text in a colorpicker by dynamically setting the text color to match the background color.
There seems to be something wrong with the last line of jquery. So far, what I have is this:
$('.color').blur(function()
{
id = $(this).attr('id');
id = id.substring(0,id.length-6);
$(id).css('color',$(this).css('background-color'));
});
and
<div id="header-wrapper">
<input class="color" id="header-wrapper-color" value="#303030">
<div id="header">
...
</div>
</div>
回答1:
$('#'+id).css('color',$(this).css('background-color'));
FIDDLE
来源:https://stackoverflow.com/questions/9674724/set-text-color-of-one-element-to-bg-color-of-another-element