Forum Moderators: open
I don't understand where's the problem. The following code displays background color of DIV2 but not the one of DIV1. Please try it.
<style>
#div1{ background-color:#333333}
</style>
<div id="div1" >asdf</div>
<div id="div2" style="background-color:#666666">asdf</div>
<script>
window.onload= function(){
var color1 = document.getElementById("div1").style.backgroundColor;
var color2 = document.getElementById("div2").style.backgroundColor;
alert(color1)
alert(color2)
}
</script>