<! Doctype html> <html> <head> <meta http-equiv = "konten tipe" content = "text/html; charset = utf-8"/> <itement> 每天一个 JavaScript 实例-获取元素当前高度 </title> <style> #date {width: 90%; tinggi: 25%; padding. function () {var height = getHeight (); console.log (tinggi); } function getHeight () {var height = 0; var div = document.getElementById ("date"). getBoundingClientRect (); if (div.height) {height = div.height; } else {height = div.bottom - div.top; } pengembalian tinggi; } </script> </head> <body> <div> <div id = "date"> </div> </div> </body> </html>