将一个元素的文本颜色设置为另一个元素的bg颜色 [英] Set text color of one element to bg color of another element
本文介绍了将一个元素的文本颜色设置为另一个元素的bg颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试通过动态设置文字颜色以匹配背景颜色,在colorpicker中创建透明文本的错觉。
I'm trying to create the illusion of transparent text in a colorpicker by dynamically setting the text color to match the background color.
似乎有错误与jquery的最后一行。
到目前为止,我拥有的是:
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'));
});
和
<div id="header-wrapper">
<input class="color" id="header-wrapper-color" value="#303030">
<div id="header">
...
</div>
</div>
推荐答案
$('#'+id).css('color',$(this).css('background-color'));
这篇关于将一个元素的文本颜色设置为另一个元素的bg颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文