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 new file mode 100644 index 0000000..b07a199 --- /dev/null +++ b/PHP and jQuery - Reduce Long String to Preview Length and Reveal Full Text OnClick.md @@ -0,0 +1,27 @@ +```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; +} +``` + +```js +$(".preview_releaser").click(function(){ +$(this).children('span').toggle('fast',function(){ +if($(this).css('display') == 'inline-block'){ +$(this).css('display','inline'); +} +}); +``` \ No newline at end of file