使用jquery增加css值 [英] Increasing css values with jquery

查看:114
本文介绍了使用jquery增加css值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jquery增加css值?

How can I increase css values with jquery?

我想增加顶部和左边的值,这是我试过但不工作: p>

I want to increase values such as top and left, this is what i tried but does not work:

var left = 5;
$(.object).css("left" + 5);

事情是,我需要的值是一个整数,而不是像5px的字符串。

the thing is that i need the value to be an integer rather than a string like "5px". I need 5 so that i can change it with numerical expressions.

推荐答案

扬基是对的:

var left = parseInt($(object).css("left")); 

$(object).css('left', left+5);

这篇关于使用jquery增加css值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆