我在解決此問題時遇到問題。我使用jQuery來調用resizeWindow函數,以便在瀏覽器窗口重新調整大小時運行。 resizeWindow函數按預期工作,但是,調整瀏覽器窗口大小似乎不會調用該函數再次運行。調整窗口大小後調用函數的問題
$(document).ready(function(){
//Bind the window onresize event
$(window).bind('resize', resizeWindow);
//Call resizeWindow() function immediately to intially set elements
$(window).bind('load', resizeWindow);
});
function resizeWindow(){
//Find all the container parent objects
$('.container').each(function(){
//Initialize the height variable
var maxHeight = 0;
//Cache the jQuery object for faster DOM access and performance
var $borders = $(this).find('.border');
//Find all the border child elements within this specific container
$borders.each(function(){
//Get current element's height
var thisHeight = $(this).height();
//Check if the current height is greater than the max height thus far
//If so, change max height to this height
if (thisHeight>maxHeight) maxHeight = thisHeight;
});
//Now that we have the maximum height of the elements,
//set that height for all the .border child elements inside the parent element
$borders.height(maxHeight);
});
}
你可以建立一個小提琴證明你的問題?你的裝訂似乎沒有問題。 – 2013-03-05 15:48:28
我沒有任何問題,使其按預期工作。小提琴會很可愛。 – 2013-03-05 15:49:46
該功能在您的頁面中調用。放一個斷點看看它。 – 2013-03-05 15:50:57