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 6594705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:50:42+00:00 2026-05-25T17:50:42+00:00

How would one return a class computed CSS property/property array? Like, if I have

  • 0

How would one return a class computed CSS property/property array?

Like, if I have a class defined in CSS:

.global {
    background-color: red;
    color: white;
    text-shadow: 0px 1px 1px black;
}

It’s applied on the go with javascript to an element. Now I want to change this elements childrens’ color to parents’ (.global) element background-color.

And is there a way to read CSS properties from a previously defined class in a style tag or externally included *.css?

Something like, getCSSData([span|.global|div > h1]); (where the passed variable is a CSS selector, that gets data for exactly matching element) that would return an object with each property in it’s own accessible variable?

Something like:

cssdata = {
    selector : '.global',
    properties : {
        backgroundColor : 'red',
        color : 'white',
        textShadow : '0px 1px 1px black'
        // plus inherited, default ones (the ones specified by W3..)
    }
}

And the usage for my previously explained example would be:

// just an example to include both, jQuery usage and/or native javascript
var elements = $('.global').children() || document.getElementsByClassName('.global')[0].children;
var data = $('.global').getCSSData() || document.getCSSData('.global');
return elements.css('color', data.properties.backgroundColor) || elements.style.backgroundColor = data.properties.backgroundColor;

Is there a function built in already in javascript/jquery and I’ve overlooked it?

If not, what should I look for to make one?

P.S. Can be DOM Level 3 too.. (HTML5’ish..)

  • 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-25T17:50:42+00:00Added an answer on May 25, 2026 at 5:50 pm

    You can access the computedStyle of an element which includes all inherited style values, here is a example that outputs the computed style of a div element in the console.

    <script type="text/javascript"> 
        if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", listComputedStyles, false);
        }
    
        function listComputedStyles() {
            var element = document.getElementById("myDiv");
            var properties = window.getComputedStyle(element, null);
    
            for (var i = 0; i < properties.length; i++)
            {
                var value = window.getComputedStyle(element, null).getPropertyValue(properties[i]);             
                console.log(properties[i], value);
            }
        }
    
    </script>
    
    <div id="myDiv" style="background-color: blue; height: 500px;"></div>
    

    You can find more information here: http://help.dottoro.com/ljscsoax.php

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

Sidebar

Related Questions

Say I have a class Code defined like this, with a user specified type
How would one pass a NSMutableArray via method return. I have it passing the
I have a query that always returns one row, with many columns. I would
How would one create a Singleton class using PHP5 classes?
How would one structure a table for an entity that can have a one
Is it good practice to create a class like the one below that can
I have a controller and I would like to require Authorization for all actions
Design -- in a perfect world I have one abstract base class A with
I have two PHP scripts. One acts as a backend, and contains a class
How would one change the class on a:link when a user is using an

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.