下面是我的JavaScript鳕鱼,我有一个问题,希望有人可以帮助我。函数columnConform不会触发并调整div的大小,直到我调整实际的浏览器窗口大小。所以函数正在工作但直到我触发窗口调整大小事件处理程序才会发生。在加载所有页面内容和DOM时,我该怎么做才能激活该函数?提前谢谢!
$(document).ready(function() {
$(function(){
jumboSlide();
columnConform();
});
function jumboSlide() {
$('#jumboSlide').carousel()
}
function resetHeight() {
$('.row-equal > div').css("min-height", 0);
}
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array();
function setConformingHeight(element, newHeight) {
element.css("min-height", newHeight);
}
function getOriginalHeight(element) {
return (element.data("originalHeight") == undefined) ? (element.outerHeight()) : (element.data("originalHeight"));
}
function columnConform() {
$('.row-equal > div').each(function() {
var $element = $(this);
var topPosition = $element.position().top;
if (currentRowStart != topPosition) {
for(currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) setConformingHeight(rowDivs[currentDiv], currentTallest);
rowDivs.length = 0;
currentRowStart = topPosition;
currentTallest = getOriginalHeight($element);
rowDivs.push($element);
} else {
rowDivs.push($element);
currentTallest = (currentTallest < getOriginalHeight($element)) ? (getOriginalHeight($element)) : (currentTallest);
}
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) setConformingHeight(rowDivs[currentDiv], currentTallest);
});
}
$(window).resize(function(){
resetHeight();
columnConform();
});
});
答案 0 :(得分:1)
您可以像这样简单地触发它:
$(window).trigger('resize');
答案 1 :(得分:1)
在准备就绪功能结束时致电columnConform();
。