<! doctype html> <html> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <title> 每天一个 javascript 实例-获取元素当前高度 </title> window.onload = function () {ความสูง var = getheight (); console.log (ความสูง); } ฟังก์ชั่น getheight () {var height = 0; var div = document.getElementById ("วันที่"). getBoundingClientRect (); if (div.height) {height = div.height; } else {height = div.bottom - div.top; } return height; } </script> </head> <body> <div> <div id = "วันที่"> </div> </div> </body> </html>