如何获取元素的创作样式属性? [英] How to get the authored style properties of an element?

查看:106
本文介绍了如何获取元素的创作样式属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery来动画页面上的元素。



为了重新初始化我所有元素的位置,我需要得到我的元素的创作属性,在我的样式表中指定%。



我首先使用 .css()函数,但它给我计算的值, 。。我正在寻找我在CSS中声明的值(百分比或像素)。



有关如何获得的任何想法?

.position()而不是 .css('top ') .css('left'),然后将值转换为百分比。


I am using jQuery to animate elements on my page.

In order to re-initialize the position of all my elements at the end, I need to get the authored properties of my elements, specified in % in my stylesheet.

I first used the .css() function but it is giving me the computed value, which I don't want. I am looking for the values I declared in the CSS (percent or pixels).

Any ideas on how to get that?

解决方案

The solution is to use .position() instead of .css('top') or .css('left'), then convert the values into percents.

这篇关于如何获取元素的创作样式属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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