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

  • Home
  • SEARCH
  • 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 9139929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:27:01+00:00 2026-06-17T09:27:01+00:00

I tried to print the list of attributes values in a specific CSS class

  • 0

I tried to print the list of attributes values in a specific CSS class with the getElementsByClassName method like below :

<html>
    <head>
        <style>
            .toto {
                width:200px;
                height:50px;
                background-color:red;
            }
        </style>
    </head>
    <body>
        <div id="lol" class="toto"></div>
        <script language="javascript" type="text/javascript">
            var toto = document.getElementsByClassName('toto');
            if (toto) {
                for (int i; i < toto.length; i++)
                    document.write(toto[i]);
            }
        </script>
    </body>
</html>

But toto.length = 1 in all cases. I would like to print the values ‘200px’, ’50px’ et ‘red’. Does anyone can help me ? Thanks a lot in advance for your help.

  • 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-06-17T09:27:02+00:00Added an answer on June 17, 2026 at 9:27 am

    If you get a reference to an element through JavaScript you can generally only get CSS properties that have been set through inline CSS using the style-attribute of the element. Properties applied through CSS can not be read through the element as properties of that element.

    You can however use window.getComputedStyle() within your loop to get the final computed CSS that has been applied to the element.

    In your case it would be something like:

    var toto = document.getElementsByClassName('toto');
    if (toto) {
       for (int i; i < toto.length; i++)
          // Log the height of each element
          console.log(getComputedStyle(toto[i], null).getPropertyValue("height"));
       }
    }
    

    Notice that the browser-support is somewhat limited (IE9+).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a linked list and when I tried to print values of the
Is it possible to print full list without using cycle? I tried: Console.WriteLine([1;2;3;4;5]) and
I am trying to print out a list of JSON object attributes. I also
I have a list of 50 values that looks like this: ['xxxxxx\n', 'xxxxxx\n', 'xxxxxx\n',
What's the DB2 Version of TSQL Print? I've tried Print 'TableName:X' And Select 'X'
in c, i tried to print out address of variable and address of some
I tried running a python script: print Hello, World! And I get this error:
I tried to implement XOR swap in python. x,y= 10,20 x,y,x = x^y,x^y,x^y print('%s
I'm having trouble making python print out texts properly aligned. I have tried everything
I've seen some code such as: out.println(print something); I tried import java.lang.System; but it's

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.