Update 'PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md'

This commit is contained in:
ben 2023-06-15 12:40:28 +00:00
parent 35be5d7968
commit b4f180878d
1 changed files with 14 additions and 17 deletions

View File

@ -2,28 +2,25 @@
/*PHP*/
static function ReduceStringForPreview($text,$size=100)
{
define($reduced,'');
if(strlen($text) > $size)
{
$reduced .= "
". substr($text, 0, $size);
$remaining = substr($text, $size);
$reduced .= "...
";
$text = $reduced;
}
return $text;
define($reduced,'');
if(strlen($text) > $size){
$reduced .= "
". substr($text, 0, $size);
$remaining = substr($text, $size);
$reduced .= "...
";
$text = $reduced;
}
return $text;
}
```
```js
/*jQuery*/
$(".preview_releaser").click(function(){
$(this).children('span').toggle('fast',function(){
if($(this).css('display') == 'inline-block'){
$(this).css('display','inline');
}
$(this).children('span').toggle('fast',function(){
if($(this).css('display') == 'inline-block'){
$(this).css('display','inline');
}
});
```