案例:jquery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="/js/jquery-1.11.1.min.js">
5
</script>
6
<script>
7
$(document).ready(function(){
8
  $("button").click(function(){
9
    var txt="";
10
    txt+="Width of div: " + $("#div1").width() + "</br>";
11
    txt+="Height of div: " + $("#div1").height();
12
    $("#div1").html(txt);
13
  });
14
});
15
</script>
16
</head>
17
<body>
18
19
<div id="div1" style="height:100px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:lightblue;"></div>
20
<br>
21
<button>显示 div 的尺寸</button>
22
<p>width() - 返回元素的宽度。</p>
23
<p>height() - 返回元素的高度。</p>
24
25
</body>
26
</html>
27