是否可以确定命名颜色的十六进制值? [英] Is it possible to determine the hex value of a named color?
本文介绍了是否可以确定命名颜色的十六进制值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以检索或计算浏览器当前使用的命名颜色的十六进制值?例如,我希望能够执行以下操作:
Is it possible to retrieve or calculate the hex value that the browser is currently using for a named color? For instance I would like to be able to do something like the following:
(Html):
<div id="container" style="background-color: lightgreen"></div>
(JavaScript):
var container = document.getElementById("container");
var colorAsHex = getHexColor(container, "background-color");
最好的是,我希望有一个我刚刚失踪的jQuery解决方案。最糟糕的是,只要我能覆盖4个主要的浏览器,就可以使用浏览器特定的黑客。
At best I'm hoping for a jQuery solution that I just happen to be missing. At worst I'm fine with browser-specific hacks as long as I can cover the 4 major browsers.
推荐答案
$('div')。css('background-color')
似乎正在工作...看到这个例子链接
$('div').css('background-color')
seems to be working ... see this example link
这篇关于是否可以确定命名颜色的十六进制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文