Set text color of one element to bg color of another element

大兔子大兔子 提交于 2019-12-11 14:33:59

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!