Max Height

by Vitaliy T

HTML

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<div class="name one">
one
</div>
<div class="name two">
two
</div>
<div class="name there">
there
</div>

CSS

.one{height: 25px; background-color: red;}
.two{height: 50px; background-color: green;}
.there{height: 75px; background-color: blue;}

JavaScript

function makeHeight(selector) {
    var maxHeight = 0;
    $(selector).each(function () {
        var currentHeight = $(this).height();
        if(currentHeight > maxHeight){
            maxHeight = currentHeight;
        }
    });
    if(maxHeight){
        $(selector).height(maxHeight);
    }
}

makeHeight('.name');