首页javascriptbackgroundjQuery Style - 如何读取/获取CSS背景颜色

jQuery Style - 如何读取/获取CSS背景颜色

我们想知道如何读取/获取CSS背景颜色。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    console.log($('#div1')[0].style.backgroundColor);
});
</script>
</head>
<body>
  <div id="div1" style="background-color: red">asdf</div>
</body>
</html>