2011-12-28 35 views
1

http://www.tigerstudiodesign.com/blog/jQuery的比賽高度不夠快

有時比賽高度不夠快,尤其是當你點擊一個鏈接到另一個頁面。除非我刷新,否則高度不會相互匹配。

代碼,我用它來搭配高度:

function matchColHeights(col1, col2) { 
    $('img').load(function() { //let images load before I get the height, else height is calculated based on text alone 
    var col1Height = $(col1).height(); 
    //alert('col1: '+col1Height); 
     var col2Height = $(col2).height(); 
     //alert('col2: '+col2Height); 
     if (col1Height < col2Height) { 
     $(col1).height(col2Height); 
     } else { 
     $(col2).height(col1Height); 
     } 
    }); 
} 

$(document).ready(function() { 
    matchColHeights('#leftPanel', '#rightPanel'); 
}); 

什麼想法?

+1

你能詳細說一下嗎?什麼代碼不起作用? – gotofritz 2011-12-28 18:41:06

+0

高度根本不夠快。它工作正常,它只是有時#leftPanel和#rightPanel高度不匹配,因爲瀏覽器無法跟上或什麼? – Lukasz 2011-12-28 20:03:37

+0

那麼,只需使用CSS樣式可見性:隱藏在兩者或其容器上,並且僅在刪除或切換到「可見」時才執行一次。 – 2011-12-28 20:11:23

回答