About 23,000,000 results
Open links in new tab
  1. background color - How to use JavaScript to change div backgroundColor ...

    Dec 9, 2009 · div.classname:hover { background-color: black; } This changes any div with the class classname to have a black background on mousover. You can basically change any …

  2. html - Change div color with javascript - Stack Overflow

    Oct 29, 2013 · Use strings for your case conditions. Amended Javascript: var selection = document.getElementById('bgcolor').value; var div = document.getElementById('change'); …

  3. HTML DOM Style backgroundColor Property - W3Schools

    The backgroundColor property sets or returns the background color of an element.

  4. How to Change Background Color with JavaScript – BG Color in …

    Jun 28, 2024 · For a example, the background color of a div with an id of container can be changed using container.style.backgroundColor = "red" . In this article, you learned how to …

  5. How to Change the Background Color of Div in JavaScript?

    To change the background color of a div using JavaScript, get reference to the element, and assign required color value to the element.style.backgroundColor property.

  6. javascript - Changing Colour of a Div with JS - Stack Overflow

    Apr 3, 2014 · var colourDiv = document.getElementById("backgroundColour"); var colours = document.getElementsByClassName('colours'); for(var i=0; i< colours.length; i++) { …

  7. How to Set Background Color for a Div Element using JavaScript

    Mar 8, 2025 · The most straightforward way to set the background color of a div element is by using the style property. You can access the style property of an HTML element and then …

  8. How to change the color of a div by clicking on it - DEV Community

    Nov 9, 2021 · This tutorial is going to be a very basic example on how to change the background color of a div element using simple javascript. Prerequisites: The only prerequisite you need, is …

  9. How to Change Background Color of a Div on Mouse Move Over …

    Apr 25, 2025 · How to Change Background Color of a Div on Mouse Move Over using JavaScript ? The background color of the div box can be easily changed using HTML, CSS, and …

  10. Change Background Color Using JavaScript - SoftAuthor

    Sep 28, 2022 · There are a few ways you can change the background color of an HTML Element dynamically in JavaScript. Using style.backgroundColor property; Using ClassList.add() Using …

  11. Some results have been removed
Refresh