当窗口大小调整或初次加载时,我调用了以下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加载文档或调整窗口大小,但事实并非如此。
这是我做错了什么,或者是我想要达到的目标?