JavaScript Compatibility Summary Obtaining Non Interline Styles Case
- 2021-07-09 07:07:41
- OfStack
Non-interline style case
#div1 {
width: 200px;
height: 200px;
background: red;
}
IE Get Non-line Styles
var oDiv = document.getElementById('div1');
oDiv.currentStyle.width;
Chrome/FF Get non-interline styles
var oDiv = document.getElementById('div1');
oDiv.getComputedStyle(oDiv,false).width;
My Compatibility Writing
var oDiv = document.getElementById('div1');
var eleWidth = oDiv.currentStyle && oDiv.currentStyle.width || getComputedStyle(oDiv,false).width;
My extended writing
function getStyle(obj,name){
return obj.currentStyle?obj.currentStyle[name]:getComputedStyle(obj,false)[name];
}
= = Note = = Above, only non-inter-line styles can be obtained, and non-room style values cannot be set.
The above is the site introduced to you JavaScript compatibility summary of the non-interline style of all narration, I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time!