Eyad Syria-lover Posted August 31, 2016 Share Posted August 31, 2016 <script> var i; for (i in window.document.body.style) { document.write("window.document.body.style."+i+"<br>"); } </script> How Can We Perform This Task? Link to comment Share on other sites More sharing options...
Ingolme Posted August 31, 2016 Share Posted August 31, 2016 It works for me. It won't work if you run that script in the <head> section because the body has not loaded yet. I would recommend using console.log() rather than document.write(). 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 31, 2016 Share Posted August 31, 2016 If you're trying to list all of the styles that apply to an element, then this note from the MDN page of the style property applies: The style property is not useful for learning about the element's style in general, since it represents only the CSS declarations set in the element's inline style attribute, not those that come from style rules elsewhere, such as style rules in the <head> section, or external style sheets. To get the values of all CSS properties for an element you should use window.getComputedStyle() instead. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now