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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:49+00:00 2026-06-11T20:47:49+00:00

Using Javascript/jQuery, is it possible to get the Property name along with it’s value

  • 0

Using Javascript/jQuery, is it possible to get the Property name along with it’s value as well as the HTML Attribute name along with it’s value for a given Element in a document. This is regardless if they are:

inline styles

<h1 style="font-weight="900">Heading 1</h1>

embedded

<style>
h1
{
font-weight: bold;
}
</style>

linked

<link href="main.css" rel="stylesheet" type="text/css" media="all" />

imported

 @import url("reset.css");

And regardless of the

  • User Agent/Browser (IE, FF, GC, AS, OP)
  • Default Styles Applied by the above
  • Versions of the above

Well, one could fireup the Firebug or the Developer Tools in FF, and similiar tools in other UA but they lack some abilities. I was looking for a jQuery plugin type where the element is displayed in the left side and all of the above shown in the right side (maybe in a iframe?).

I simply make a document (a very simple maybe with just one element say ) and have it displayed on the left side in my browser and the above displayed at the right.

  • 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-11T20:47:50+00:00Added an answer on June 11, 2026 at 8:47 pm

    You can use the getComputedStyle() method of the document object and the attributes field of the element:

    var oDiv = document.getElementById("div1");
    var css = document.defaultView.getComputedStyle(oDiv, null);
    var attr = oDiv.attributes;
    

    This should return an object with fields for each CSS style the element has. You can then write a simple, depth-first tree-walk to iterate over every element in the DOM (I wrote this with jQuery to make it easy to follow):

    var stack = new Array();
    stack.push($('html')[0]);
    var i = 0;
    while(stack.length > 0 && i < 100){
        //pop the next element off the stack
        var ele = stack.pop();
    
        var css = document.defaultView.getComputedStyle(ele, null);
        var attr = ele.attributes;
    
        //do things with the css object
        console.log(css);
    
        //do things with the attributes
        console.log(attr);
    
        //add children to the stack
        $(ele).children().each(function(index, child){
            stack.push(child);
        });
        i++;
    }
    

    Note that I put a counter (i) in there to limit the number of iterations to 100 and keep you from blowing up your browser if your page has a ton of elements. You can remove this if you want, but be careful. Also note that the root of your search can be any node in the DOM, but I started with the html tag.

    Based on your comments, I’m going to walk through how you would implement this. Keep in mind that all it does is print the CSS/attribute object to the console, you will need to modify that part to do what you actually want it to.

    Script:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
    <script type="text/javascript">
    function doStuff(){
      var stack = new Array();
      stack.push($('html')[0]);
      var i = 0;
      while(stack.length > 0 && i < 100){
        //pop the next element off the stack
        var ele = stack.pop();
    
        var css = document.defaultView.getComputedStyle(ele, null);
        var attr = ele.attributes;
    
        //do things with the css object
        console.log(css);
    
        //do things with the attributes
        console.log(attr);
    
        //add children to the stack
        $(ele).children().each(function(index, child){
            stack.push(child);
        });
        i++;
      }        
    }
    </script>
    

    HTML Button to run it

    <button type="button" onclick="doStuff()">Click Me!</button>
    

    Full implementation

    <!DOCTYPE html>
    <html>
    <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
    <script type="text/javascript">
    function doStuff(){
      var stack = new Array();
      stack.push($('html')[0]);
      var i = 0;
      while(stack.length > 0 && i < 100){
        //pop the next element off the stack
        var ele = stack.pop();
    
        var css = document.defaultView.getComputedStyle(ele, null);
        var attr = ele.attributes;
    
        //do things with the css object
        console.log(css);
    
        //do things with the attributes
        console.log(attr);
    
        //add children to the stack
        $(ele).children().each(function(index, child){
            stack.push(child);
        });
        i++;
      }        
    }
    </script>
    </head>
    <body>
      <button type="button" onclick="doStuff()">Click Me!</button>
    </body>
    </html>
    

    I’d be interested to hear what you’re trying to accomplish with this. This is a slow operation, and there’s not usually much benefit to examining the tags that you put on the page…

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

Sidebar

Related Questions

Is it possible to get the top position of an element using javascript/jquery ?
Is it in any way possible, using javascript (jquery), html (5) to get a
Is it possible to convert html tags to html entities using javascript/jquery using any
Possible Duplicate: Prevent any form of page refresh using jQuery/Javascript how can i prevent
Possible Duplicate: javascript: pause setTimeout(); Im using jQuery and working on a notification system
I'm trying to make a drop down menu using javascript/jquery but can't get my
I'm using some javascript/jquery in an asp.net mvc view and I'm appending some html
Is this possible to get result from a php file without using jQuery ?
Possible Duplicate: Kill Ajax requests using JavaScript using jQuery Here is the simple code
Possible Duplicate: is it possible to get cross domain SOAP request using jquery please

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.