jQuery.each( ["Left", "Top"], function( i, name ) {
var method = "scroll" + name;
- jQuery.fn[ method ] = function(val) {
+ jQuery.fn[ method ] = function( val ) {
var elem, win;
- if(val === undefined) {
- elem = this[0];
+ if( val === undefined ) {
+ elem = this[ 0 ];
if( !elem ) {
return null;
}
-
+
win = getWindow( elem );
// Return the scroll offset
return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
win.document.body[ method ] :
elem[ method ];
}
-
+
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
if ( win ) {
win.scrollTo(
- !i ? val : jQuery(win).scrollLeft(),
- i ? val : jQuery(win).scrollTop()
+ !i ? val : jQuery( win ).scrollLeft(),
+ i ? val : jQuery( win ).scrollTop()
);
-
} else {
this[ method ] = val;
}