首页javascriptwidthjQuery Style - 如何设置元素宽度和高度

jQuery Style - 如何设置元素宽度和高度

我们想知道如何设置元素宽度和高度。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.js'></script>
<style type='text/css'>
div {
  height: 100px;
  background: blue
}
</style>
<script type='text/javascript'>
$(function(){
    $('div').css({
        'width': 'auto',
        'height': '500px'
    });
});
</script>
</head>
<body>
  <div>hello</div>
</body>
</html>