嘿伙计们希望你们能帮助我
我有一个奇怪的问题。我正在处理一个有两个浮动 div(以及许多其他内容)的网页。为了使浮动 div 的高度相等,我添加了以下代码
$(document).ready(function(){
alert($('#body-left').height());
if($('#body-left').height()>$('#sidebar').height()){
$('#sidebar').height($('#body-left').height());
}
else{
$('#body-left').height($('#sidebar').height());
}
});
请参阅“alert($('#body-left').height());”行,当我删除该行时,它停止工作:/。IE :
这是我不添加 alert() 行时发生的情况:
这就是我添加警告行时发生的情况
任何想法为什么会这样?:/
抱歉,回复晚了,但我得到了它的使用
if($('#body-left').height()>$('#sidebar').height()){
setTimeout(function(){
$('#sidebar').height($('#body-left').height());
},100);
}
else{
setTimeout(function(){
$('#body-left').height($('#sidebar').height());
},100);
}
有任何想法吗?