Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 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:
// usage: $(elem).css('backgroundPosition');
// ticket:
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 :
[,"backgroundPositionX"), "px ",,"backgroundPositionY"), "px"].join("");
} else {
return _css.apply(this,arguments);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment