I have a div with applied some inline style as rgba(0,255,0,1)
and I am using ...style.borderColor
to return a string with its color value.
I have noticed if alpha channel is 1 (no transparency) the value returned is only in rgb
format, if instead color applied as some transparency like rgba(0,255,0,0.5)
values is returned correctly in rgba
.
- Do you know any way to force an
rgba
(with alpha) to be returned instead? - If no how could I add this value, string manipulation is a good way?
var elm = document.querySelector('#target');
console.log(elm.style.borderColor);
<div id="target" style=" width: 150px; height:150px; background-color:red; border-color: rgba(0,255,0,1); border-width: 20px; border-style: solid;"></div>