Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Element style

Posted by: Windsurfer Oct 14 2022, 11:12 AM

I have a site and some pages have no values in the element.style but the other pages do.
What would be the reason for that ?

Posted by: Christian J Oct 14 2022, 11:55 AM

Impossible to say without seeing the pages in question, but generally speaking it could depend on how the style properties were set to begin with:

"The style property is not useful for completely learning about the styles applied on the element, 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."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style




Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)