How to change background color in javascirpt

singleButton({name:“On”, action:“digitalWrite”,
pin:“4”, value:“HIGH”,bgcolor:“green”,
shape:“rectangle”,align:“left”,“text_color”:“red” })

singleButton({name:“Off”, action:“digitalWrite”,
pin:“4”, value:“LOW”, bgcolor:“red”,
shape:“rectangle”, align:“left”, text_color:“yellow”})

Your code looks correct. Can you share a screenshot of the code and the output your are getting when you open the page? I want to verify what output is shown to you so that I can help you further.

I wanted a code for changing bg color. This code is only for button.

Hi @begmohdmohsin

You can change the background color in JavaScript by using the document.body.style.backgroundColor property. Below is the the updated code to change background color in JavaScript.

singleButton({name:"On", action:"digitalWrite",
        pin:"4", value:"HIGH",bgcolor:"green",
        shape:"rectangle",align:"left","text_color":"red" })

singleButton({name:"Off", action:"digitalWrite",
              pin:"4", value:"LOW", bgcolor:"red",
              shape:"rectangle", align:"left", text_color:"yellow"})
              
// Set background color for the page
document.body.style.backgroundColor = "lightblue"; 

Please make sure that the pin value matches the hardware connection. This code must change the background color. If you still find issues please feel free to get back to us.