user992731
user992731

Reputation: 3520

Increment Margin Top each time function is called

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

Answers (1)

Sampson
Sampson

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

Related Questions