Increment css top property using jquery

前端 未结 5 1379
醉话见心
醉话见心 2020-12-24 02:03

I have the following div :

What is the best way to

5条回答
  •  悲&欢浪女
    2020-12-24 02:07

    I would say create a variable, increment the variable, and then reset the property using the new value, like this

    var topProperty = 0;   //You can also populate this variable with the current value.
    

    then in your click event

    {
    topProperty += 10;
    $('#new').css('top', topProperty + 'px');
    }
    

提交回复
热议问题