Skip to content

Instantly share code, notes, and snippets.

@daniellealexis
Created August 22, 2016 01:24
Show Gist options
  • Save daniellealexis/664243f54d21170e4e608addcb8204cd to your computer and use it in GitHub Desktop.
Save daniellealexis/664243f54d21170e4e608addcb8204cd to your computer and use it in GitHub Desktop.
Shorthand for jQuery .css without knowing the current value
var $element = $('#myThing'),
elementPaddingLeft = $element.css('paddingLeft'),
newValue = elementPaddingLeft + 20;
$element.css('paddingLeft', newValue);
// How about all at once?
var $element = $('#myThing');
$element.css('paddingLeft', '+=20');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment