<! Doctype html> <html> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <title> 每天一个 javascript 实例-获取元素当前高度 </title> <estilo> #date {width: 90%; window.onload = function () {var altura = getHeight (); console.log (altura); } função getHeight () {var altura = 0; var div = document.getElementById ("date"). getBoundingClientRect (); if (div.Height) {Hight = div.Height; } else {Hight = div.Bottom - Div.top; } altura de retorno; } </script> </ad Head> <body> <div> <div id = "date"> </div> </div> </body> </html>