I have this code which generates the RGB values from a hex code.
<script>
var s = "<?php the_field('phpvariableforcolour'); ?>";
var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
var matches = patt.exec(s);
var rgb = "rgb("+parseInt(matches[1], 16)+","+parseInt(matches[2], 16)+","+parseInt(matches[3], 16)+");";
alert(rgb);
</script>
I want to then apply the rgb variable (which is currently in an alert) to an inline css style where the RGB values appear e.g. rgba(0,0,0,0.0) : -
background-image: -webkit-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,0.2));
background-image: -moz-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,0.2));
background-image: -o-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,0.2));
background-image: -ms-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,0.2));
background-image: linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,0.2));
I can't see to find a way to do this, with jQuery I can add background-image, but not all these.