jQuery $("body").height() returns undefined

jQuery $("body").height() returns undefined

本文关键字:quot returns undefined height jQuery body      更新时间:2023-09-26

我有一个这样的电话:

$("#ContextMenuModal").height($("body").height());

但是,当我在Firebug中查看它时,$("body").height()返回未定义。

什么会导致 jQuery 返回未定义的身高?

我正在使用jQuery 1.4.1。

编辑:

这是在 iFrame 中

只需使用

$(document).height() // - $('body').offset().top

和/或

$(window).height()

而是 $('body').height()

扩展一点,

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document

正如bažmegakapa指出的那样,尽管只有几个像素,但略有不同。正文的真实高度可以通过从文档高度中减去正文偏移量来计算(就像我上面提到的):

$(document).height() - $('body').offset().top

使用这个-

 $("body").css("height")

好吧,我会说不需要jquery-

this.style.height;//it will not work if you add it as inline js.