當窗口大小調整或初次加載時,我調用了以下JQuery。我有一些問題,它似乎沒有按照預期的第一次加載工作。有人能告訴我什麼是故障嗎?Jquery在頁面加載/調整大小時調整div的大小
的JQuery(1.8.3)
function setContentHeight() {
var height = $(document).height();
$('#content, #content > div:first-child').height(height - 242);
$('#content-text-description').height(height - 280);
}
$(window).resize(function(e) {
setContentHeight();
});
$(document).ready(function(e) {
setContentHeight();
});
HTML
<body>
<div id="container">
<div id="banner"></div> <!-- Header -->
<div id="navi"></div> <!-- Navigation Pane -->
<div id="content"> <!-- Content loaded with include -->
<div id="home"> <!-- Start of content -->
<div id="content-text-description"></div> <!-- container for custom scroller -->
</div>
<div id="footer"></div> <!-- Footer -->
</div>
</body>
CSS
body {
margin:0;
font-family:"Century Gothic";
line-height:30px;
}
#container {
width:1024px;
margin: 0 auto;
}
#banner {
width:1024px;
}
#content {
width:1024px;
height:470px;
z-index:98;
float:left;
top:-7px;
overflow:hidden;
}
#footer {
text-align:center;
background:#59585D;
position:absolute;
bottom:0px;
width:1024px;
height:30px;
font-size:12px;
color:#ffffff;
}
#content-text-description {
padding-top:20px;
display:block;
width:800px;
z-index:3;
overflow:auto;
}
據我所知,通過調整要求按預期的JQuery位應有的功能div加載文檔或調整窗口大小,但事實並非如此。
這是我做錯了什麼,或者是我想要達到的目標?