I just want to know how to use the jquery .css() function to not overwrite, but to add additional values to css properties.
For instance, I have an element that is curre
Since transform
is kind of a shorthand, the values must be combined... There's no increment method.
What you could do, is retrieve the previous value and append the new one:
Updated JsFiddle
var rotation = 0;
function rotate() {
rotation += 90;
var rotationString = 'rotate(' + rotation + 'deg)';
var prev = $('#square').css('transform');
$('#square').css('transform', prev + " " + rotationString);
}