[SOLVED] Change color of a button in html canvas


hello,everyone, i want to change the background-color of button at clicking it. my jsand html code is followed:
< button id=“button” onclick=“changeColor()”>click me < /button>
function changeColor(){button.style.backgroundColor=“red”;}

but it doesn’t work in ubidots,so i want to ask, how can i solve this problem, because i try this codes in w3s and it works.
thannkyou in advance.


Dear @luca123,

In the article below you can find an example that includes a background color change, feel free to adapt it to your needs.

Anyway, as attached files I share with you a single script using JS to change a div color inside the html canvas, please keep in mind that the html canvas is intended for users with knowledge of CSS, HTML and JS, if you are not familiar with these concepts we advise you to learn about them before of trying to use the widget.

All the best,
Maria C.

html canvas.zip (1.0 KB)