There is a block:
var $size = 155; if ($('.review-cont').height() > $size) { $('.review-cont').addClass('re-hide'); $('<span>', { text: 'Подробнее', class: 're-open' }).appendTo('.review-bottom'); $(".re-open").click(function() { $(this).siblings('.review-cont').toggleClass('re-hide').toggleClass('re-full'); var $button = $(this); $button.text($button.text() == "Подробнее" ? "Закрыть" : "Подробнее"); }); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="review"> <div class="review-top">имг</div> <div class="review-middle"> <p class="review-name">текст</p> <p class="review-location">еще текст</p> </div> <div class="review-bottom"> <div class="review-cont">КОНТЕНТ</div> </div> </div> There are many such units. From the task everything is simple - if the specified block exceeds the height specified in the script, then add the class and the button.
But the problem is that if one of the many blocks fits into the height specified in the script, then the script does not work out not only for this block, but for all the others.
How to make the height was considered in each case independently? I assume the use of this , but did not understand how to fit it.