How to check for CSS class existence in JavaScript without jQuery?

I am writing a reusable .NET / Sitecore control that spills out some HTML elements with specific CSS classes. I would like to provide a set of default CSS definitions for these classes, but only if there was nothing in the page load, will it allow default formatting, but for this it will be redefined outside the control.

Is there a reliable cross-browser way, preferably without jQuery, to determine in JavaScript whether a previously existing CSS class definition exists?

0
source share
2 answers

You should look at document.styleSheets

+3
source

, , ... CSS : "". , ( ) . , CSS, ( CSS, , , prio , ).

, , - , . javascript , ( , , , ...).

, , javascript .

-1

All Articles