0

I know that I can get a specific property

$('somediv').css('position')

But I want to get all of the properties that are set on $('somediv')

What I'm trying to do is create an entry in a .css file based on $('somediv'). I won't know what styles will be set on $('somediv') so I'm looking for a way to get all the styles with out explicitly requesting each one.

Anthony Hilyard
  • 1,220
  • 12
  • 27
Sam Luther
  • 1,170
  • 3
  • 18
  • 38
  • 1
    Use [`window.getComputedStyle()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) – Dave Jul 30 '15 at 21:15
  • Sounds like an x/y problem to me? Why would you create entries in css files based on styles the element already have. – adeneo Jul 30 '15 at 21:23
  • Because you are talking about creating a CSS entry in a file, maybe you can consider using a browser extension / add-in rather than trying to the detail you seek using code. The following is a link to a free chrome extension that I use for that purpose: http://selectorgadget.com/ – David Tansey Jul 30 '15 at 21:24
  • @adeneo it's a template, styles are applied and saved – Sam Luther Jul 30 '15 at 21:33
  • @SamLuther but many style properties will be inherited...doesn't make a lot of sense. Are you wanting to parse inline styles? – charlietfl Jul 30 '15 at 22:15
  • @charlietfl na, it makes sense. I think the possible duplicate of this question is the solution I'm looking for smarty pantz :) – Sam Luther Jul 30 '15 at 22:21

0 Answers0