我用下面的代码具有相等的高度rightpos
,leftpos
和middlepos
的div:JQuery的div.height是错误的Chrome浏览器进行所有的div相同的高度
<script>
jQuery.noConflict();
jQuery(document).ready(function($){
// Find the greatest height:
maxHeight = Math.max($('#rightpos').height(), $('#middlepos').height());
maxHeight = Math.max(maxHeight, $('#leftpos').height());
// Set height:
$('#rightpos').height(maxHeight);
$('#middlepos').height(maxHeight);
$('#leftpos').height(maxHeight);
})
</script>
使用这个最高的div确定主要页面http://yaskawa.ir/的方式在Firefox中运行良好,但在Chrome中遇到问题。
更新1后Sparky672的回答是:
我可以看到,这段代码中,alert('test here');
末不起作用。
<script>
jQuery.noConflict();
//jQuery(document).ready(function($){});
jQuery(window).load(function($){
// Find the greatest height:
maxHeight = Math.max($('#rightpos').height(), $('#middlepos').height());
maxHeight = Math.max(maxHeight, $('#leftpos').height());
// Set height:
$('#rightpos').height(maxHeight);
$('#middlepos').height(maxHeight);
$('#leftpos').height(maxHeight);
alert('test here');
})
</script>
我看到所有的div的有(使用Chrome)相同的高度。有什么问题? – Kedume
我在Linux中使用铬,它有问题。我现在将上传照片 –
请构建你的问题的jsFiddle。 'window.load'在这里工作正常:http://jsfiddle.net/snBLP/3/ – Sparky