Sologet Forum
How to read more / hide text using Jquery and PHP - Printable Version

+- Sologet Forum (https://www.sologet.com)
+-- Forum: Programming (https://www.sologet.com/Forum-Programming)
+--- Forum: PHP Programming & Tutorials (https://www.sologet.com/Forum-PHP-Programming-Tutorials)
+--- Thread: How to read more / hide text using Jquery and PHP (/Thread-How-to-read-more-hide-text-using-Jquery-and-PHP)



How to read more / hide text using Jquery and PHP - Kingsolomon - 10-31-2018

If you have set your php site to display post excerpts on the front or home page, you will want visitors to click on the read more link and show full text after click on hide link show small text see below code.

PHP and HTML Code

Code:
<div id="smallRead">
    <?php
       $string = $profileinfo['description'];
       if (strlen($string) > 150) {
           $stringCut = substr($string, 0, 150);
           $endPoint = strrpos($stringCut, ' ');
           $string = $endPoint? substr($stringCut, 0, $endPoint):substr($stringCut, 0);
           $string .= '... <a style="cursor: pointer;" id="HideReadmoreDisplay">Read More</a>';
       }
       echo $string;
       ?>
</div>
<div id="FullRead" style="display: none;">
    <? echo strip_tags($profileinfo['description']).'... <a style="cursor: pointer;" id="ReadmoreDisplay">Hide</a>'; ?>
</div>



Jquery Code

Code:
<script type="text/javascript">
   $('#ReadmoreDisplay').click(function(){
       $('#FullRead').hide();
       $('#smallRead').show();
   });
   $('#HideReadmoreDisplay').click(function(){
       $('#smallRead').hide();
       $('#FullRead').show();
   });
</script>



RE: How to read more / hide text using Jquery and PHP - Shugudun - 04-14-2020

Php is a good way for visitors to read more or hide text on your site

https://jiji.ng/alimosho/computer-and-it-services/get-all-php-script-here-investment-script-bank-script-e-commerce-JEpc66MkjHSnzJ3qc6UI20i.html?lid=8YsChyGWEzADG4Vs&cur_pos=1&pos=1&ads_count=15&ads_per_page=15&page=1