Reputation: 3520
I am trying to increment my margin-top each time my function is called. Shouldn't this work?
$('.btn-default').css("marginTop", parseInt($(this).css("marginTop") +=28));
Upvotes: 1
Views: 86
Reputation: 268424
With jQuery's $.fn.css
method (as of jQuery 1.6) you only need to pass in the relative values portion. It will determine the base value for you:
$(".btn-default").css("marginTop", "+=28");
Source: http://api.jquery.com/css/#css-propertyName-value
Upvotes: 2