Javascript examples for CSS Style Property:backgroundColor
Get the background color of a specific <div> element:
<!DOCTYPE html> <html> <body> <h1>Hello World!</h1> <div id="myDiv" style="background-color:orange;">This is a div element.</div> <br> <button type="button" onclick="myFunction()">Get the background color of div</button> <script> function myFunction() {/*from w w w .j a va 2 s.c o m*/ console.log(document.getElementById("myDiv").style.backgroundColor); } </script> </body> </html>