我有这段代码使所有div.column具有相同的高度。很好。
问题是div.column内部包含可扩展元素,并且此代码仅在加载页面时执行。
页面中的每一次单击都可以重新执行相同的代码吗?
代码:
jQuery(function($){
$(document).ready(function(){
// Select and loop the container element of the elements you want to equalise
$('.container').each(function(){
// Cache the highest
var highestBox = 0;
// Select and loop the elements you want to equalise
$('.column', this).each(function(){
// If this box is higher than the cached highest then store it
if($(this).height() > highestBox) {
highestBox = $(this).height();
}
});
// Set the height of all those children to whichever was highest
$('.column',this).height(highestBox);
});
});
});