Created
April 4, 2019 10:03
-
-
Save hakeempazhu/4d800866a110d4616144e32840d40f3f to your computer and use it in GitHub Desktop.
Read more option in php with collapse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<?php | |
$string = strip_tags($property['description_en']); | |
$n=strlen($string); | |
if ($n > 500) { | |
// truncate string | |
$newstring = substr($string, 0, 500); | |
$newstring .= '<span id="more">... <a href="" class="bold" id="viewmore" data-toggle="collapse" data-target="#demo" >Read More</a></span>'; | |
$balance = substr($string,500, $n); | |
echo $newstring; | |
} | |
else | |
{ | |
echo $string; | |
} | |
?><span id="demo" class="collapse"><?php echo $balance; ?></span> | |
</p> | |
<!-- JQuery --> | |
<script> | |
$("#viewmore").click(function(){ | |
$("#more").hide(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment