How would you change the background colour of a div with the id "colourme" to purple?

var div=document.getElementById("colourme"); div.style.backgroundColor = "purple"

GH

Related Javascript Mentoring answers

All answers ▸

How are objects created in arrays


What does the following code do and why? console.log(1+"2")


How to check if value exists in an object in JavaScript?


Suppose that you have a <p> element with an id of 'id1'. Use javascript to set the inner html of this element to 'hello!'