<! DocType html> <html> <head> <meta http-äquiv = "content-type" content = "text/html; charset = utf-8"/> <title> 每天一个 Javascript 实例-获取元素当前高度 </title> <style> #date {WidthTh: 90%; Höhe: 25%; window.onload = function () {var high = getheight (); console.log (Höhe); } function getheight () {var height = 0; var div = document.getElementById ("Datum"). getBoundingClientRect (); if (div.height) {height = div.height; } else {height = div.bottom - div.top; } Rückkehrhöhe; } </script> </head> <body> <div> <div id = "date"> </div> </div> </body> </html>