jQuery元素css尺寸方法

jQuery元素css尺寸方法

jQuery 提供多个处理尺寸的重要方法: width() height() innerWidth() innerHeight() outerWidth() outerHeight()

1,jQuery width() 和 height() 方法

$(“button”).click(function(){ var txt=””; txt+=”div 的宽度是: ” + $(“#div1”).width() + “</br>”; txt+=”div 的高度是: ” + $(“#div1”).height(); $(“#div1”).html(“www.96net.com”); });

2,jQuery innerWidth() 和 innerHeight() 方法

$(button).click(function(){ var txt=; txt+=div 宽度,包含内边距: + $(#div1).innerWidth() + </br>; txt+=div 高度,包含内边距: + $(#div1).innerHeight(); $(#div1).html(“www.96net.com.cn”); });

3,jQuery outerWidth() 和 outerHeight() 方法

$(button).click(function(){ var txt=; txt+=div 宽度,包含内边距和边框: + $(#div1).outerWidth() + </br>; txt+=div 高度,包含内边距和边框: + $(#div1).outerHeight(); $(#div1).html(“www.96net.com.cn”); });