Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:22:58+00:00 2026-05-17T01:22:58+00:00

I want to load the key value pairs from a class, or id, in

  • 0

I want to load the key value pairs from a class, or id, in a CSS stylesheet into a JavaScript object in order to access the data.

Note that I do NOT want to add that class to a DOM element (at least not directly)

The only way I can see in JQuery is to create a dummy hidden element, add my class to it using

$(“#dummy").addClass(“myclass”);

and then query that using

$(“#dummy”).(cssproperty);

But even there I want to see each css property, without knowing what they are in advance.

What I really need is something simple that loads a CSS class into a hash.
I’m not seeing that in jQuery… is there something in regular JavaScript?

thanks
–Rob

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:22:58+00:00Added an answer on May 17, 2026 at 1:22 am

    Two options for you:

    1) The Stylesheet object

    …discussed here and here. That gives you direct access to the class definition, from which you can read the style properties directly and apply them to your DOM element.

    Sadly, I don’t have time to dash off an example right now, but the links above have them. Basically, you loop through the stylesheets (document.styleSheets) and for each stylesheet, loop through the cssRules (rules on some browsers). Each rule has a selectorText telling you what its selector looks like (“.foo” or whatever). When you find the rule with the selector matching your class, you can loop through the properties on its style property using for (name in rule.style), with the value being rule.style[name] inside the loop.

    2) getComputedStyle:

    Do as you said and apply the class to an off-page element, then use the getComputedStyle (MDC, MSDN) function to get the style object for its computed style. Be careful, though, as the computed style may have items that are inherited (e.g., from styles applied to all children of body or even html).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create some YAML key with value - the code in php.
I am creating a web-based IMAP client in Rails, and want to cache the
I'm trying to decide on the best way to load in some configuration settings.
I want tho have I18N categories table. I have followed the jobeet example .
Here's my setup: myTextField is bound to a key in the Shared User Defaults
I am wondering whether I am overusing java reflection. I have a class which
In my JSF 1.2 webapp I have a page with a <h:commandButton> that invokes
I have 2 arraylists. One is principleList which contains integer values that denotes roles
I have a model Image that has a propery named uploaded_by_user that is a
I am working in the .NET 2.0 framework. I have some code working, just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.