使用jQuery获取*所有* CSS属性 [英] Get *all* CSS attributes with jQuery

查看:105
本文介绍了使用jQuery获取*所有* CSS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是使用jQuery获取一个css属性的方法:



$('someObject')css c $ c>



如何获得他们全部? (未指定,最好采用以下格式,以便以后可以重新应用jQuery):

  cssObj = {
'overflow':'hidden',
'height':'100%',
'position':'absolute',
}
/ pre>

谢谢!



EDIT b

我试图获得的方法是在样式表中声明的(它们不是内联的)。对不指定。

解决方案

这样的事情:



http:/ /stackoverflow.com/questions/1004475/jquery-css-plugin-that-returns-computed-style-of-element-to-pseudo-clone-that-ele



这是丑陋的,但它似乎工作的海报...



这也可能是感兴趣的:
https://developer.mozilla.org/en/DOM:window.getComputedStyle


Here's how you get one css attribute using jQuery:

$('someObject').css('attribute')

How do you get them all? (without specifying and preferably in the following format so it can be reapplied with jQuery later):

    cssObj = {
        'overflow':'hidden',
        'height':'100%',
        'position':'absolute',
    }

Thanks!!

EDIT

The methods I'm trying to get are declared in a style sheet (they are not inline). Sorry for not specifying.

解决方案

What about something like this:

http://stackoverflow.com/questions/1004475/jquery-css-plugin-that-returns-computed-style-of-element-to-pseudo-clone-that-ele

It is ugly, but it appeared to work for the poster...

This also may be of interest: https://developer.mozilla.org/en/DOM:window.getComputedStyle

这篇关于使用jQuery获取*所有* CSS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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