Created
August 22, 2016 01:24
-
-
Save daniellealexis/664243f54d21170e4e608addcb8204cd to your computer and use it in GitHub Desktop.
Shorthand for jQuery .css without knowing the current value
This file contains hidden or 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
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