Than you very much for the support.
This code did the work. Just that it does not keep formatting
<script>
function myCustomReadmoreFunction() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("mycustomreadmore");
var btnText = document.getElementById("myCustomReadmoreBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
</script>
<?php echo substr(strip_tags(@$cat['s_description']), 0, 720) . (strlen(strip_tags(@$cat['s_description'])) > 720 ? '...' : ''); ?>
<span id="dots">...</span><span id="mycustomreadmore" style="display: none" >
</pr> <?php echo substr(strip_tags(@$cat['s_description']), 720, 9000020) . (strlen(strip_tags(@$cat['s_description'])) > 720 ? '' : ''); ?>
</span>
<button onclick="myCustomReadmoreFunction()" id="myCustomReadmoreBtn" class="btn btn-transparent">Read more</button>
If you remove strip_tags
, all the content displays at once. The code doesn't work effectively. Aside that this code does the work just that the formatting is removed because of strip_tags