Skip to content
Advertisement

How to get class of a CSS style

I fetch all css styles for an element by using this code:

JavaScript

so far so good.

I need to know if there styles and if, which class brings the CSS styles to this list.

For example we look the result line with

JavaScript

I need to know if there is a class that applies this style and if there is a class which name has this class and in best case from which CSS file it is.

If there is a way to get this, info what is the best way to do that?

Advertisement

Answer

The below code is tested in my localhost. I have used jQuery.

HTML

JavaScript

Stylesheet-2

JavaScript

Stylesheet

JavaScript

And i got the console.log result of which stylesheet and which class.

Thank you.

enter image description here

Advertisement