<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
#div1 {
width:100px;
height:100px;
background: red;
}
</style>
</head> <body>
<div id="div1"></div>
<script type="text/javascript">
var odiv=document.getElementById('div1');
if(odiv.currentStyle){
alert(odiv.currentStyle.backgroundColor)
}
else
{
alert(getComputedStyle(odiv,false).backgroundColor);
}
</script>
</body>
</html>