Skip to content

I try to change the background color at on small app in html css js

I try to change the background color at on small app in html css js one snap of this is:

var myoutput = document.getElementById("output");

function roundNum(){
AlphaValue=0.4;
RedValue=255;
GreenValue=0;
BlueValue=0;
outputColor=[RedValue,GreenValue,+BlueValue,AlphaValue];
return outputColor;
}
myColor=roundNum();
myColor1=myColor[0];
myColor2=myColor[1];
myColor3=myColor[2];
myColor4=myColor[3];
myoutput.style.backgroundColor ="( 
rgba("+myColor1+","+myColor2+","+myColor3+","+myColor4+");";

Answer

Remove the ( from the first of your string, And remove ; at the end.

Change:

myoutput.style.backgroundColor ="(rgba("+myColor1+","+myColor2+","+myColor3+","+myColor4+");";

To:

myoutput.style.backgroundColor ="rgba("+myColor1+","+myColor2+","+myColor3+","+myColor4+")";