1 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
2 jQuery.each([ "Height", "Width" ], function(i, name){
4 var tl = name == "Height" ? "Top" : "Left", // top or left
5 br = name == "Height" ? "Bottom" : "Right"; // bottom or right
7 // innerHeight and innerWidth
8 jQuery.fn["inner" + name] = function(){
9 return this[ name.toLowerCase() ]() +
10 num(this, "padding" + tl) +
11 num(this, "padding" + br);
14 // outerHeight and outerWidth
15 jQuery.fn["outer" + name] = function(margin) {
16 return this["inner" + name]() +
17 num(this, "border" + tl + "Width") +
18 num(this, "border" + br + "Width") +
20 num(this, "margin" + tl) + num(this, "margin" + br) : 0);
25 function num(elem, prop) {
26 elem = elem.jquery ? elem[0] : elem;
27 return elem && parseInt( jQuery.curCSS(elem, prop, true), 10 ) || 0;