There are three styles in CSS, which are inline style inner style external style sheet
1.style
Syntax: element.style.xxx This can only get the inline style properties, get the style can read can write
2.currentStyle
Syntax: element.currentstyle[xxx] can get internal and external styles, but only IE browser compatible, get the style can only read
Example: Document.createlement (' div '). currentstyle[' width '] gets the width of the element
3.getComputedStyle
Syntax: window.getComputedStyle (element,null). XXX Document.defaultView.getComputedStyle (element,null). xxx
function and currentstyle the same but not for IE browser, you will get all the original elements of the element, even if the element is not set any style, the second way of writing from the jquery source code, is the. css () the underlying operation method.
Can write a function that is compatible with all browsers to get its style
function GetStyle (element,property) { return Document.defaultView.getComputedStyle? Document.defaultView.getComputedStyle (element,false) [property]: Element.currentstyle[property];}
Get CSS properties of Style getComputedStyle Currentstyle three different ways to summarize