【问题标题】:Increment Margin Top each time function is called每次调用函数时递增保证金顶部
【发布时间】:2015-01-16 18:46:36
【问题描述】:

我试图在每次调用我的函数时增加我的 margin-top。这不应该工作吗?

$('.btn-default').css("marginTop", parseInt($(this).css("marginTop") +=28));

【问题讨论】:

标签: jquery margin increment


【解决方案1】:

使用 jQuery 的 $.fn.css 方法(从 jQuery 1.6 开始),您只需要传入相对值部分。它将为您确定基值:

$(".btn-default").css("marginTop", "+=28");

来源:http://api.jquery.com/css/#css-propertyName-value

【讨论】:

    猜你喜欢
    • 2016-05-14
    • 2018-05-16
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 2020-03-20
    • 2019-10-03
    • 1970-01-01
    • 2016-09-28
    相关资源
    最近更新 更多