<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div>888</div> </body> <script> function getstyle(obj, style) { if(obj.currentStyle){ return obj.currentStyle[style] //ie下获取样式 }else { return document.defaultView.getComputedStyle(obj,null)[style]//谷歌,火狐下获取默认样式 } } const div = document.querySelector('.el'); console.log(getstyle(div,'display')) </script> </html>