I want to modify the color attribute that is returned in JQuery. So, lets assume the color is returned and is contained in a
var color
color = 'rgb(148, 141, 124)'
I want to modify the value of color to be:
color = 'rgb(148, 141, 124, .7)'
(in other words, insert the string ", .7")
Try,
var color = 'rgb(148, 141, 124)';
var newColor = color.slice(0,-1) + ",.7)"
If you want it to be rgba then use,
var color = 'rgb(148, 141, 124)';
var newColor = (color.slice(0,-1) + ",.7)").split('(').join('a(');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With