I am exploring a way to extract key value pairs from a CSS stylesheet related to a specific class or id into a JavaScript object for data accessibility.
It is important to mention that I do not intend to apply this class directly to any DOM elements.
In my search, the only method I have discovered in JQuery involves creating a hidden dummy element and adding the class to it using:
$(“#dummy").addClass(“myclass”);
After which, I can query the properties using:
$(“#dummy”).css(property);
However, I am looking for a solution that allows me to view each css property individually without prior knowledge of what they are.
Ideally, I would like a straightforward process that loads a CSS class into a hash. Is there a native JavaScript alternative to achieve this? Any insights would be appreciated.
Thank you, -Rob