Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6199439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:11:20+00:00 2026-05-24T04:11:20+00:00

In JavaScript, the className property gives the class name of an HTML element, but

  • 0

In JavaScript, the className property gives the class name of an HTML element, but how to get the contents of the class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:11:21+00:00Added an answer on May 24, 2026 at 4:11 am

    first you need to get the cssRules array but since it is not cross platform you should use a code like this:

    if ( document.styleSheets[0].cssRules ) {
        var cssRules = document.styleSheets[0].cssRules;
    } else if ( document.styleSheets[0].rules ) {
        var cssRules = document.styleSheets[0].rules;
    }
    

    now cssRules is an array of selectors in your stylesheet you can go through it like this:

    for( var i = 0; i < cssRules.length; ++i ) {
         if( cssRules[i].selectorText == '.myClass' ) {
             alert( cssRules[i].style.color );
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way using jquery/javascript to get a class name when I
So I have this text generated by a javascript plugin. <a class=className>Text</a> a.className {
I am trying to change the class of an element using javascript. So far
The javascript code is like below. var ADDRESS = { checkit : function(element){ if(event.target.className
How to check class name using javascript?? I am using this statement.. if (document.getElementByClass(expandable)
Working with JavaScript in IE, I used the reflected property but the problem is
javascript with> var customer=document.getElementById('custList').value; and that works... Why does it work BUT... var customer=(form1.custList.value);
I have this code on javascript side: function changeSelectionStyle(id) { if(document.getElementById(id).className != 'yes'){ document.getElementById(id).className
I have some trivial JavaScript to effect a style change: sel = document.getElementById('my_id'); sel.className
I had some help and some suggestions on how to remove a class name.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.