<!doctype html> <html> <head> <meta http-equiv =“ content-type” content =“ text/html; charset = utf-8”/> <title> <title>每天一个javascript实例-javascript实例-获取元素当前高度</title> </title> </title> </title> </title> <syle> <样式> #date {width:90%; 90%; 90%; = function(){var height = getheight(); console.log(高度); }函数getheight(){var height = 0; var div = document.getElementById(“ date”)。getBoundingClientRect(); if(div.height){height = div.height; } else {height = div.bottom -div.top; }返回高度; } </script> </head> <body> <div> <div id =“ date”> </div> </div> </div> </body> </html>