mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
Started work on new attr plugin - will provide a ton of accessors for common styles and attributes.
This commit is contained in:
parent
4ab5a88bc4
commit
40fdf0ad5c
37
attr/attr.js
Normal file
37
attr/attr.js
Normal file
@ -0,0 +1,37 @@
|
||||
var pos = [
|
||||
"height", "width", "top", "left", "bottom", "right",
|
||||
"paddingTop", "paddingRight", "paddingBottom", "paddingLeft",
|
||||
"marginTop", "marginRight", "marginBottom", "marginLeft",
|
||||
"lineHeight", "maxWidth", "maxHeight", "minWidth", "minHeight",
|
||||
"textIndent", "fontSize"
|
||||
];
|
||||
|
||||
for ( var i = 0; i < pos.length; i++ ) {
|
||||
(function(){
|
||||
var o = pos[i];
|
||||
$.fn[o] = function(a){
|
||||
return a ?
|
||||
this.css(o,a) :
|
||||
parseInt( this.css(o) );
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
var posArg = [
|
||||
"clientLeft", "clientTop", "clientWidth", "clientHeight",
|
||||
"offsetLeft", "offsetTop", "offsetWidth", "offsetHeight",
|
||||
"scrollLeft", "scrollTop", "scrollWidth", "scrollHeight"
|
||||
];
|
||||
|
||||
for ( var i = 0; i < posArg.length; i++ ) {
|
||||
(function(){
|
||||
var o = posArg[i];
|
||||
$.fn[o] = function(a){
|
||||
return a ? this.each(function(){
|
||||
this[o] = parseInt( a );
|
||||
}) : this.size() > 0 ?
|
||||
this.get(0)[o] :
|
||||
null;
|
||||
};
|
||||
})();
|
||||
}
|
Loading…
Reference in New Issue
Block a user