Skip to content

Instantly share code, notes, and snippets.

@sungraiz
Created March 5, 2020 11:03
Show Gist options
  • Select an option

  • Save sungraiz/add5c6dc6b0cb57e5d1f24483a359e59 to your computer and use it in GitHub Desktop.

Select an option

Save sungraiz/add5c6dc6b0cb57e5d1f24483a359e59 to your computer and use it in GitHub Desktop.
/* Child Theme - Custom JS File for Users to add their own JS code */
(function($){
function equalHeights(){
// Select and loop the container element of the elements you want to equalise
$(document).find('.rh_latest-properties.rhea_properties_default').each(function(){
// Cache the highest
var highestBox = 0;
// Select and loop the elements you want to equalise
$('.rh_prop_card__details_elementor', 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
$('.rh_prop_card__details_elementor',this).height(highestBox);
});
}
window.addEventListener('DOMContentLoaded', function(){
if($('.rh_latest-properties.rhea_properties_default').length > 0){
equalHeights();
let ids = $('.rh_latest-properties.rhea_properties_default').map(function() {
return $(this).attr('id');
});
// Select the node that will be observed for mutations
const targetNode = document.getElementById(ids[0]);
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Create an observer instance linked to the callback function
const observer = new MutationObserver(equalHeights);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment