A connection to the PROPERTY-PANEL in this case is → NOT ← needed!
Since the event gets fired from onReady-Code-Part!
- Check if you really leave the viewPort!
- Check if you setted-up your button to 100% opacity in the property-panel (this is neccessary, if you want to work with style-colors.
Test your code and its function generating another example first!
- Create a button on your page!
- Paste this code onto your page (make sure you do not have multiple onReady-code-parts in your code!
- Press the button! (You did not forget to set the opacity to 100% first, in the property panel ?)
Setting the opacity back to transparent!
$w('#button1').style.backgroundColor = "rgba(255,255,255, 0)";
$w.onReady(()=>{
$w('#button1').style.backgroundColor = "rgba(255,255,255, 0)";
$w('#button1').onClick(()=>{console.log("button clicked!")
$w('#button1').style.backgroundColor = "blue";
});
});
Another version: RGB
$w.onReady(()=>{
$w('#button1').onClick(()=>{console.log("button clicked!")
$w('#button1').style.backgroundColor = "rgb(155,245,155)";
});
});
Another version: RGBA
$w.onReady(()=>{
$w('#button1').onClick(()=>{console.log("button clicked!")
$w('#button1').style.backgroundColor = "rgba(155,245,155, 0.5)";
});
});