From b4f180878df7edc1b7ab71918d566736d619c87b Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 15 Jun 2023 12:40:28 +0000 Subject: [PATCH] Update 'PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md' --- ...iew Length and Reveal Full Text OnClick.md | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md b/PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md index bf4ea16..d7619be 100644 --- a/PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md +++ b/PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md @@ -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'); + } }); ``` \ No newline at end of file