JSFiddle - React, Tailwind, and code Playground
by liormb
HTML
<div id="first"></div>
<div id="second"></div>
CSS
#first {
position: relative;
width: 200px;
height: 200px;
background-color: rgb(100,100,100);
}
#second {
position: absolute;
top: 150px;
left: 150px;
width: 100px;
height: 100px;
background-color: rgb(221,0,0);
}
JavaScript
$(document).ready(function() {
add_alpha_channel();
});
function add_alpha_channel()
{
var oldBGColor = $('#second').css('backgroundColor');
var newBGColor = oldBGColor.replace('rgb', 'rgba').replace(')', ',.8)');
$('#second').css({'background-color': newBGColor});
}