<! doctype html> <html> <head> <meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8"/> <title> 每天一个 javaScript 实例-获取元素当前高度 </title> <style> #date {width: 90 ٪ ؛ window.onload = function () {var height = getheight () ؛ console.log (الارتفاع) ؛ } وظيفة getheight () {var height = 0 ؛ var div = document.getElementById ("date"). getBoundingClientRect () ؛ if (div.height) {height = div.height ؛ } آخر {height = div.bottom - div.top ؛ } ارتفاع الإرجاع ؛ } </script> </head> <body> <viv> <div id = "date"