Change container box color on click

Hi, I’m trying to use wix style api to dynamically change the color of a container box on click.
But even after using this code the color does not change. But console logging the color shows the new color-
$w(“#myElement”).style.backgroundColor = “rgba(255,0,0,0.5)”;

How can I update the color in display??

Hi,
Have you remembered to change the (" #myElement ") to your actual element’s ID?
If you did please share the rest of the code so we can inspect.

Hi,
Yes I have changed the code correctly, here is the code

let goalsnumber=1;

$w("#button118").onClick( (event, $w) => { 

if (goalsnumber<=3)
{
$w(“#checkbox1”).checked= true ;
$w(“#button118”).style.backgroundColor=“rgba(0,0,255,0.5)”;
console.log($w(“#button118”).style.backgroundColor);
goalsnumber++;
}

}); 

this shows the console output as rgba(0,0,255,0.5) but the color of the element doesn’t change in the viewport

Please share your editor’s URL so we can inspect.

Hi,
here’s the editor url