首页javascriptcss_attributejQuery Style - 如何获得计算风格

jQuery Style - 如何获得计算风格

我们想知道如何获得计算风格。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.4.js'></script>
<style type='text/css'>
#foo {
  display: none;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    var foo = document.getElementById('foo');
    var $output = $("#output");
    $output.text(getComputedStyle(foo).display);
});
</script>
</head>
<body>
  <div id="foo">Foo Bar</div>
  <h2 id="output"></h2>
</body>
</html>