How can you determine if a css class exists with Javascript?

gidmanma提出了一个问题:How can you determine if a css class exists with Javascript?,或许与您遇到的问题类似。

回答者CommunityHelen给出了该问题的处理方式:

This should be possible to do using the document.styleSheets[].rules[].selectorText and document.styleSheets[].imports[].rules[].selectorText properties. Refer to MDN documentation.

希望本文对你有帮助,欢迎支持JavaScript中文网