Numeric CSS properties can be incremented and decremented with the +=
and -=
syntax, respectively, using the .css()
method:
// Increment using the += syntax
$("#target-element").css("font-size", "+=10");
// You can also specify the unit to increment by
$("#target-element").css("width", "+=100pt");
$("#target-element").css("top", "+=30px");
$("#target-element").css("left", "+=3em");
// Decrementing is done by using the -= syntax
$("#target-element").css("height", "-=50pt");