JQuery学习之jQuery尺寸

1.width()和height()方法:

width():设置或返回元素的宽度(不包括内边距,边框或外边距)

height():设置或返回元素的高度(不包括内边距,边框或外边距)

$("button").click(function(){

  var txt="";

  txt+="Width: " + $("#div1").width() + "</br>";

  txt+="Height: " + $("#div1").height();

  $("#div1").html(txt);

});

 

2.innerWidth()和innerHeight()方法:

innerWidth():返回元素的宽度(包括内边距)

innerHeight():返回元素的高度(包括内边距)

$("button").click(function(){

  var txt="";

  txt+="Inner width: " + $("#div1").innerWidth() + "</br>";

  txt+="Inner height: " + $("#div1").innerHeight();

  $("#div1").html(txt);

});

 

3.outerWidth()和outerHeight()方法:

outerWidth():返回元素的高度(包括内边距和边框)

outerHeight():返回元素的高度(包括内边距和边框)

$("button").click(function(){

  var txt="";

  txt+="Outer width: " + $("#div1").outerWidth() + "</br>";

  txt+="Outer height: " + $("#div1").outerHeight();

  $("#div1").html(txt);

});

posted @ 2016-10-18 19:18  小春熙子  阅读(127)  评论(0编辑  收藏  举报