我在解决此问题时遇到问题。我使用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