{myadvertisements[zone_1]}
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read more / hide text using Jquery and PHP
#1
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>
To Purchase Credit Click here , For how to make money on Sologet forum Click here 

HIRE ME FOR WEBSITE DESIGNING USE THE PM BUTTON TO SEND ME MESSAGE

There is love in sharing
{myadvertisements[zone_3]}
  


Messages In This Thread
How to read more / hide text using Jquery and PHP - by Kingsolomon - 10-31-2018, 02:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  technical help john8520 0 126 01-29-2021, 05:35 AM
Last Post: john8520
  TIPS How to add one day in current date using php Kingsolomon 1 1,578 04-14-2020, 01:16 AM
Last Post: Shugudun
  How to session timeout warning with countdown using PHP, Ajax and HTML Kingsolomon 1 1,301 04-14-2020, 01:10 AM
Last Post: Shugudun
  TIPS How to get Page Loading Time using PHP Kingsolomon 2 1,502 04-14-2020, 01:01 AM
Last Post: Shugudun
  How to limit text length in php and provide 'Read more' link Kingsolomon 1 1,559 04-14-2020, 12:43 AM
Last Post: Shugudun

Forum Jump:


Users browsing this thread:
1 Guest(s)

{myadvertisements[zone_2]}
How to read more / hide text using Jquery and PHP00