Created
January 12, 2010 04:41
-
-
Save paulirish/274913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The CSS property backgroundPosition does not exist in the accessible DOM properties within IE 8. | |
// this css() method duck punch retifies that issue | |
// see also: http://paulirish.com/2010/duck-punching-with-jquery/ | |
// usage: $(elem).css('backgroundPosition'); | |
// ticket: http://dev.jquery.com/ticket/5749 | |
(function($){ | |
var _css = $.fn.css; | |
$.fn.css = function(name,val){ | |
if (!val && /^background(-p|P)osition$/.test(name)){ | |
var value = _css.apply(this,arguments); | |
return value !== undefined ? value : | |
[_css.call(this,"backgroundPositionX"), "px ", | |
_css.call(this,"backgroundPositionY"), "px"].join(""); | |
} else { | |
return _css.apply(this,arguments); | |
} | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment