简体   繁体   English

如何在JavaScript中获取颜色为“白色”的RGB颜色代码?

[英]How to get rgb color code of color 'white' in javascript?

我想要一个将颜色名称作为参数的javascript函数,它返回颜色rgb代码。

You could set the style to a html element, let's say the <div id='d1'></div> 您可以将样式设置为html元素,例如<div id='d1'></div>

then you could check the computed color: 那么您可以检查计算出的颜色:

    var d1 = document.getElementById('d1')
    var color = window.getComputedStyle(d1, null)['color']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM