如何通过javascript将颜色从(rrr ggg bbb)转换为RRGGBB [英] How to convert color from (rrr ggg bbb) to RRGGBB by javascript

查看:230
本文介绍了如何通过javascript将颜色从(rrr ggg bbb)转换为RRGGBB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码(在Selenium IDE中):
storeEval | window.document.defaultView.getComputedStyle(window.document.getElementsByTagName('input')[0])。getPropertyValue('background-color')|结果

I have this code (in Selenium IDE): storeEval | window.document.defaultView.getComputedStyle(window.document.getElementsByTagName('input')[0]).getPropertyValue('background-color') | result

它返回中的颜色(rrr,ggg,bbb),如何我可以在 RRGGBB 中获得这种颜色吗?

it's returns me color in (rrr, ggg, bbb), how can i get this color in RRGGBB?

推荐答案

试试这个:

command: storeEval
target : color = window.document.defaultView.getComputedStyle(window.document.getElementsByTagName('input')[0]).getPropertyValue('background-color'); colorArr = color.replace(/[(rgb()\)]/g, '').split(','); hexString = parseInt(colorArr[0]).toString(16) + parseInt(colorArr[1]).toString(16) + parseInt(colorArr[2]).toString(16);
value  : result

这篇关于如何通过javascript将颜色从(rrr ggg bbb)转换为RRGGBB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆