首页javascriptwidthjQuery Style - 如何将div的宽度设置为screen.width

jQuery Style - 如何将div的宽度设置为screen.width

我们想知道如何将div的宽度设置为screen.width。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.3.js'></script>
<style type='text/css'>
#mainBody {
  background: #f0eded;
  height: 98px;
  margin-top: 5px;
  width: 100px;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $("#mainBody").css('width', screen.width);
});
</script>
</head>
<body>
  <div id="mainBody"></div>
</body>
</html>