Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the .css() method in jQuery support changing rgba values?

Tags:

jquery

css

I have a <div> which has a rgba css value (transparent), which I want to change on a click of a button which is in a different <div>. The problem is that I am changing the color to a hex value and I can't seem to get rgba to work. Code will be posted only if needed. My question is if .css() supports rgba

like image 611
Angel Vasilev Avatar asked Jun 27 '26 06:06

Angel Vasilev


1 Answers

Try like this

var value1=$('#themeBackground1').val();
var opacity=$('#themeOpct1').val();
var rgbData=hexToRgb(value1);
value1='rgba('+rgbData.r+','+rgbData.g+','+rgbData.b+','+opacity+') !important;';
selector.attr('style', 'background-color:'+value1);
like image 72
Bibhudatta Sahoo Avatar answered Jun 29 '26 19:06

Bibhudatta Sahoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!