2

I'm looking for a way to get all css styles of an element that are defined in external stylesheet ( style.css ? ) or in HTML ( inline css ).

All solutions i found tend to return [object] so user can apply to another Element.

The following code prints all elements not just those that are defined.

$(this).css("cssText");

Any idea ?

4
  • Why are you trying to do this? Commented Dec 27, 2013 at 21:53
  • SO user can change styles from GUI. Using .css("cssText") will generate loads of input boxes and will indeed frustrate the end user. Commented Dec 27, 2013 at 21:56
  • Possible answer here? Commented Dec 27, 2013 at 21:57
  • i get " Type Error: " Commented Dec 27, 2013 at 22:11

1 Answer 1

0
<script>    
    $("div").each(function(){       
        /* FROM EXTERNAL CSS STYLESHEET */    
        var currentStyle = this.currentStyle
        var opacityStyle = currentStyle.opacity /* get opacity for example */
    })
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

The problem is that styles vary from element to element. I dont know what elements are defined in external stylesheet for element, say, X.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.