Created
October 23, 2009 04:44
-
-
Save paulirish/216655 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
// css() upgrade for a few shorthand values | |
// paul irish. MIT license. | |
// by default you can't do $(elem).css('margin'), but instead $(elem).css('marginTop') and so on. | |
// this monkeypatch allows lets you retrieve all four values in shorthand style: | |
// e.g. $(this).css('padding') | |
(function($){ | |
var css = $.fn.css, methods = {'padding':1,'margin':1}, dirs = 'Top Right Bottom Left'.split(' '); | |
$.fn.css = function(prop,val){ | |
var jq = this; | |
if ( val || !(prop in methods)) return css.apply(jq,arguments); | |
return $.map(dirs, function(k){ return css.call(jq,prop+k) }).join(' '); | |
} | |
})(jQuery); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment