是否可以确定命名颜色的十六进制值? [英] 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解决方案,
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')
似乎工作...看这个例子 link
$('div').css('background-color')
seems to be working ... see this example link
这篇关于是否可以确定命名颜色的十六进制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文