I have the following jquery code to resize a set of elements so that they are all the same height of the tallest element. The function works fine when i refresh the screen, but the $(window).resize() doesn't seem to work.
jQuery(document).ready(function($) {
function equal_height(target) {
var maxHeight = -1;
$(target).each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$(target).each(function() {
$(this).height(maxHeight);
});
};
var responsive_viewport = $(window).width();
if (responsive_viewport >= 768) {
equal_height('.cta-text');
$(window).resize(function() {
equal_height('.cta-text');
});
}
});