I'm trying to find out how to limit the characters on the mobile display using php. I have made the character limit (700 characters) work fine. I want the character limit on the mobile display to be 150 characters. How do I implement it in PHP?
PHP (Laravel)
@if (strlen($val->getByLang('id')->description) > 700)
<div class="section-description desc-more">
{!! substr($val->getByLang('id')->description, 0, 700).'...' !!}
<span class="view-more">Read More</span>
</div>
<div class="section-description desc-full" style="display: none;">
{!! $val->getByLang('id')->description !!}
<span class="view-less">Show Less</span>
</div>
@else
<div class="section-description">
{!! $val->getByLang('id')->description !!}
</div>
@endif
Javascript
$('.view-more').on('click', function () {
$('.desc-more').hide();
$('.desc-full').show();
});
$('.view-less').on('click', function () {
$('.desc-full').hide();
$('.desc-more').show();
});
Aucun commentaire:
Enregistrer un commentaire