How to get all css style properties from / by the classname? How to find a class in the stylsheets?2019 Community Moderator ElectionCan jQuery get all CSS styles associated with an element?How do I remove a property from a JavaScript object?How to get the value from the GET parameters?How to remove all CSS classes using jQuery?How to style a <select> dropdown with only CSS?How can I remove a style added with .css() function?How to style a checkbox using CSS?Why do browsers match CSS selectors from right to left?Reset/remove CSS styles for element onlyRemove blue border from css custom-styled button in ChromeHow to get class of a css style

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

The meaning of the "at the of"

Best mythical creature to use as livestock?

How does Dispel Magic work against Stoneskin?

Extension of Splitting Fields over An Arbitrary Field

My adviser wants to be the first author

What exactly is the purpose of connection links straped between the rocket and the launch pad

Is all copper pipe pretty much the same?

Excess Zinc in garden soil

Am I not good enough for you?

How is the Swiss post e-voting system supposed to work, and how was it wrong?

Do I need to leave some extra space available on the disk which my database log files reside, for log backup operations to successfully occur?

Want to switch to tankless, but can I use my existing wiring?

Are there situations where a child is permitted to refer to their parent by their first name?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

Word for a person who has no opinion about whether god exists

Why would a jet engine that runs at temps excess of 2000°C burn when it crashes?

Welcoming 2019 Pi day: How to draw the letter π?

What wound would be of little consequence to a biped but terrible for a quadruped?

Time dilation for a moving electronic clock

Silly Sally's Movie

Does the Bracer of Flying Daggers benefit from the Dueling fighting style?

Replacing Windows 7 security updates with anti-virus?

Humans have energy, but not water. What happens?



How to get all css style properties from / by the classname? How to find a class in the stylsheets?



2019 Community Moderator ElectionCan jQuery get all CSS styles associated with an element?How do I remove a property from a JavaScript object?How to get the value from the GET parameters?How to remove all CSS classes using jQuery?How to style a <select> dropdown with only CSS?How can I remove a style added with .css() function?How to style a checkbox using CSS?Why do browsers match CSS selectors from right to left?Reset/remove CSS styles for element onlyRemove blue border from css custom-styled button in ChromeHow to get class of a css style










-2















I need to get all css properties for each classes wich matched a element.



I have the classnames of my element from



this.className


How can I now get all the css-styles for each classname?



Maybe I must compare or search in the stylesheets?



var sheets = document.styleSheets;


I only know the way to get the css-styles for the element but not for the classname.



Thanks for helping.



Update
This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question.










share|improve this question
























  • show your code please

    – לבני מלכה
    Mar 7 at 11:05











  • there is no more code, its a generaly question how its possible to get the style-properties of a css-class from the stylesheets.

    – mikeD
    Mar 7 at 11:13











  • Possible duplicate of Can jQuery get all CSS styles associated with an element?

    – לבני מלכה
    Mar 7 at 11:16











  • This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question

    – mikeD
    Mar 7 at 11:21












  • Yes, document.styleSheets is the right keyword. You will have to go through all stylesheets, go through their rules, and see if the selector matches what you are looking for. (Having to deal with order and specificity might come on top of that.)

    – 04FS
    Mar 7 at 11:26
















-2















I need to get all css properties for each classes wich matched a element.



I have the classnames of my element from



this.className


How can I now get all the css-styles for each classname?



Maybe I must compare or search in the stylesheets?



var sheets = document.styleSheets;


I only know the way to get the css-styles for the element but not for the classname.



Thanks for helping.



Update
This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question.










share|improve this question
























  • show your code please

    – לבני מלכה
    Mar 7 at 11:05











  • there is no more code, its a generaly question how its possible to get the style-properties of a css-class from the stylesheets.

    – mikeD
    Mar 7 at 11:13











  • Possible duplicate of Can jQuery get all CSS styles associated with an element?

    – לבני מלכה
    Mar 7 at 11:16











  • This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question

    – mikeD
    Mar 7 at 11:21












  • Yes, document.styleSheets is the right keyword. You will have to go through all stylesheets, go through their rules, and see if the selector matches what you are looking for. (Having to deal with order and specificity might come on top of that.)

    – 04FS
    Mar 7 at 11:26














-2












-2








-2








I need to get all css properties for each classes wich matched a element.



I have the classnames of my element from



this.className


How can I now get all the css-styles for each classname?



Maybe I must compare or search in the stylesheets?



var sheets = document.styleSheets;


I only know the way to get the css-styles for the element but not for the classname.



Thanks for helping.



Update
This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question.










share|improve this question
















I need to get all css properties for each classes wich matched a element.



I have the classnames of my element from



this.className


How can I now get all the css-styles for each classname?



Maybe I must compare or search in the stylesheets?



var sheets = document.styleSheets;


I only know the way to get the css-styles for the element but not for the classname.



Thanks for helping.



Update
This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question.







javascript jquery css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 12:47









Siong Thye Goh

1,3281916




1,3281916










asked Mar 7 at 11:03









mikeDmikeD

858




858












  • show your code please

    – לבני מלכה
    Mar 7 at 11:05











  • there is no more code, its a generaly question how its possible to get the style-properties of a css-class from the stylesheets.

    – mikeD
    Mar 7 at 11:13











  • Possible duplicate of Can jQuery get all CSS styles associated with an element?

    – לבני מלכה
    Mar 7 at 11:16











  • This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question

    – mikeD
    Mar 7 at 11:21












  • Yes, document.styleSheets is the right keyword. You will have to go through all stylesheets, go through their rules, and see if the selector matches what you are looking for. (Having to deal with order and specificity might come on top of that.)

    – 04FS
    Mar 7 at 11:26


















  • show your code please

    – לבני מלכה
    Mar 7 at 11:05











  • there is no more code, its a generaly question how its possible to get the style-properties of a css-class from the stylesheets.

    – mikeD
    Mar 7 at 11:13











  • Possible duplicate of Can jQuery get all CSS styles associated with an element?

    – לבני מלכה
    Mar 7 at 11:16











  • This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question

    – mikeD
    Mar 7 at 11:21












  • Yes, document.styleSheets is the right keyword. You will have to go through all stylesheets, go through their rules, and see if the selector matches what you are looking for. (Having to deal with order and specificity might come on top of that.)

    – 04FS
    Mar 7 at 11:26

















show your code please

– לבני מלכה
Mar 7 at 11:05





show your code please

– לבני מלכה
Mar 7 at 11:05













there is no more code, its a generaly question how its possible to get the style-properties of a css-class from the stylesheets.

– mikeD
Mar 7 at 11:13





there is no more code, its a generaly question how its possible to get the style-properties of a css-class from the stylesheets.

– mikeD
Mar 7 at 11:13













Possible duplicate of Can jQuery get all CSS styles associated with an element?

– לבני מלכה
Mar 7 at 11:16





Possible duplicate of Can jQuery get all CSS styles associated with an element?

– לבני מלכה
Mar 7 at 11:16













This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question

– mikeD
Mar 7 at 11:21






This is no duclicate, i'm not looking for all kind of css properties. I looking specially only for the properties of a css-class, so i think it's a unique question

– mikeD
Mar 7 at 11:21














Yes, document.styleSheets is the right keyword. You will have to go through all stylesheets, go through their rules, and see if the selector matches what you are looking for. (Having to deal with order and specificity might come on top of that.)

– 04FS
Mar 7 at 11:26






Yes, document.styleSheets is the right keyword. You will have to go through all stylesheets, go through their rules, and see if the selector matches what you are looking for. (Having to deal with order and specificity might come on top of that.)

– 04FS
Mar 7 at 11:26













2 Answers
2






active

oldest

votes


















1














Use getAttribute to get the styles. This works for inline css only






document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>








share|improve this answer























  • Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

    – mikeD
    Mar 7 at 11:12











  • Check this out stackoverflow.com/questions/754607/…

    – ellipsis
    Mar 7 at 11:17











  • i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

    – mikeD
    Mar 7 at 11:22


















1














document.styleSheets[index] from this object you can get needed information for CSS class. You have to just write a function which will do a search within



document.styleSheets[0].cssRules or document.styleSheets[0].rules by checking 


selectorText is equal to needed class name and then get that objects cssText or style.cssText property.






share|improve this answer























  • yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

    – mikeD
    Mar 7 at 11:39











  • Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

    – Emin Javadov
    Mar 7 at 11:59











  • mmh, could you make me s small example, my tries failed

    – mikeD
    Mar 7 at 12:28










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042276%2fhow-to-get-all-css-style-properties-from-by-the-classname-how-to-find-a-class%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Use getAttribute to get the styles. This works for inline css only






document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>








share|improve this answer























  • Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

    – mikeD
    Mar 7 at 11:12











  • Check this out stackoverflow.com/questions/754607/…

    – ellipsis
    Mar 7 at 11:17











  • i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

    – mikeD
    Mar 7 at 11:22















1














Use getAttribute to get the styles. This works for inline css only






document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>








share|improve this answer























  • Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

    – mikeD
    Mar 7 at 11:12











  • Check this out stackoverflow.com/questions/754607/…

    – ellipsis
    Mar 7 at 11:17











  • i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

    – mikeD
    Mar 7 at 11:22













1












1








1







Use getAttribute to get the styles. This works for inline css only






document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>








share|improve this answer













Use getAttribute to get the styles. This works for inline css only






document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>








document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>





document.querySelectorAll('.a').forEach(e=>console.log(e.getAttribute('style')))

<div class="a" style="color:red"></div>
<div class="a" style="color:blue"></div>






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 11:05









ellipsisellipsis

7,9092929




7,9092929












  • Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

    – mikeD
    Mar 7 at 11:12











  • Check this out stackoverflow.com/questions/754607/…

    – ellipsis
    Mar 7 at 11:17











  • i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

    – mikeD
    Mar 7 at 11:22

















  • Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

    – mikeD
    Mar 7 at 11:12











  • Check this out stackoverflow.com/questions/754607/…

    – ellipsis
    Mar 7 at 11:17











  • i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

    – mikeD
    Mar 7 at 11:22
















Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

– mikeD
Mar 7 at 11:12





Yes thats the problem, i need to work with the styles from the stylesheet not from the inlinestyle. I must compare later inlinestyle with style of style-sheets.

– mikeD
Mar 7 at 11:12













Check this out stackoverflow.com/questions/754607/…

– ellipsis
Mar 7 at 11:17





Check this out stackoverflow.com/questions/754607/…

– ellipsis
Mar 7 at 11:17













i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

– mikeD
Mar 7 at 11:22





i know this, but it helps me not much. I need a way only for getting the properties of one class not all possible styles...

– mikeD
Mar 7 at 11:22













1














document.styleSheets[index] from this object you can get needed information for CSS class. You have to just write a function which will do a search within



document.styleSheets[0].cssRules or document.styleSheets[0].rules by checking 


selectorText is equal to needed class name and then get that objects cssText or style.cssText property.






share|improve this answer























  • yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

    – mikeD
    Mar 7 at 11:39











  • Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

    – Emin Javadov
    Mar 7 at 11:59











  • mmh, could you make me s small example, my tries failed

    – mikeD
    Mar 7 at 12:28















1














document.styleSheets[index] from this object you can get needed information for CSS class. You have to just write a function which will do a search within



document.styleSheets[0].cssRules or document.styleSheets[0].rules by checking 


selectorText is equal to needed class name and then get that objects cssText or style.cssText property.






share|improve this answer























  • yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

    – mikeD
    Mar 7 at 11:39











  • Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

    – Emin Javadov
    Mar 7 at 11:59











  • mmh, could you make me s small example, my tries failed

    – mikeD
    Mar 7 at 12:28













1












1








1







document.styleSheets[index] from this object you can get needed information for CSS class. You have to just write a function which will do a search within



document.styleSheets[0].cssRules or document.styleSheets[0].rules by checking 


selectorText is equal to needed class name and then get that objects cssText or style.cssText property.






share|improve this answer













document.styleSheets[index] from this object you can get needed information for CSS class. You have to just write a function which will do a search within



document.styleSheets[0].cssRules or document.styleSheets[0].rules by checking 


selectorText is equal to needed class name and then get that objects cssText or style.cssText property.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 11:29









Emin JavadovEmin Javadov

10118




10118












  • yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

    – mikeD
    Mar 7 at 11:39











  • Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

    – Emin Javadov
    Mar 7 at 11:59











  • mmh, could you make me s small example, my tries failed

    – mikeD
    Mar 7 at 12:28

















  • yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

    – mikeD
    Mar 7 at 11:39











  • Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

    – Emin Javadov
    Mar 7 at 11:59











  • mmh, could you make me s small example, my tries failed

    – mikeD
    Mar 7 at 12:28
















yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

– mikeD
Mar 7 at 11:39





yes i think that could be the way, can i check each stylesheet in a kind like that if(stylesheet[0].cssRules[classname_i_looking_for].length)...?

– mikeD
Mar 7 at 11:39













Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

– Emin Javadov
Mar 7 at 11:59





Just check both of document.styleSheets[0].rules || document.styleSheets[0].cssRules properties in loop for selectorText equality to your css class name and then get same objects cssText property for declared css properties

– Emin Javadov
Mar 7 at 11:59













mmh, could you make me s small example, my tries failed

– mikeD
Mar 7 at 12:28





mmh, could you make me s small example, my tries failed

– mikeD
Mar 7 at 12:28

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042276%2fhow-to-get-all-css-style-properties-from-by-the-classname-how-to-find-a-class%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme