通过js获取元素的css样式属性

var display = this.currentStyle? this.currentStyle.display: window.getComputedStyle(this, null).display;

这样可以获取定义在内部~外部样式表以及内嵌的所有的样式~当然这里指获取display属性~简单来说就是只要定义了display~不管在哪里设置的~都可以获取出来

你可能感兴趣的:(通过js获取元素的css样式属性)