[英]jQuery $(“body”).height() returns 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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.