Return 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> <p id="demo"></p> <script> function myFunction() {/*from www . j ava2s . c om*/ document.getElementById("demo").innerHTML =document.getElementById("myDiv").style.backgroundColor; } </script> </body> </html>