@GitDem

Как поставить условие скрытия в многострочном тексте?

<div class="model-listing__list">
    <span class="model-listing__list__item">Production countries:</span>
    <span class="model-listing__list__param country js-read-more-content-descr">Germany, Poland, Belgium, Hungary, Austia, 
           Spain, United Kingdom, France, Germany, Poland, Belgium, Hungary, Austia, Spain, United Kingdom, France</span>
    <div class="model-listing__list__more js-read-more-show-descr">Открыть</div>
    <div class="model-listing__list__more js-read-more-hide-descr">Закрыть</div>
</div>

let lineClamp = (2 * 20)
    $('.country').each(function (heightbl) {
        var heightBlock = $(this).height();
        if (lineClamp > heightBlock) {
            $(this).css({
                'height': '100%',
                'overflow-y': 'visible',
                'background': 'blue',
            });
        }
        else {
            $(this).css({
                'height': lineClamp,
                'overflow-y': 'hidden',
                'background': 'green',
            });
        }
    });

Как поставить условие, если города занимают две строчки то кнопки скрыть, если больше двух строк то кнопки видны
  • Вопрос задан
  • 41 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 14:10
500 руб./за проект
19 апр. 2024, в 13:31
10000 руб./за проект