jQuery $(“body”)。height()返回undefined

我有一个这样的电话:

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

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

什么会导致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.