Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $.fn.sameHeight = function() {
- var selector = this;
- var heights = [];
- // Save the heights of every element into an array
- selector.each(function(){
- var height = $(this).height();
- heights.push(height);
- });
- // Get the biggest height
- var maxHeight = Math.max.apply(null, heights);
- // Show in the console to verify
- console.log(heights,maxHeight);
- // Set the maxHeight to every selected element
- selector.each(function(){
- $(this).height(maxHeight);
- });
- };
- $(document).ready(function() {
- //use the.sameHeight()-Function for all elements, which shall have the same height, seperately
- $('.product-grid-view .product-title a').sameHeight();
- $('.owl-carousel .atw_item_title a').sameHeight();
- $(window).resize(function(){
- // Do it when the window resizes too
- $('.product-grid-view .product-title a').css('height', '');
- $('.product-grid-view .product-title a').sameHeight();
- $('.owl-carousel .atw_item_title a').css('height', '');
- $('.owl-carousel .atw_item_title a').sameHeight();
- });
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement