1$(document).ready(function() {
2
3 var showChar = 100;
4 var ellipsestext = "...";
5 var moretext = "Show more >";
6 var lesstext = "Show less";
7
8
9 $('.more').each(function() {
10 var content = $(this).html();
11
12 if(content.length > showChar) {
13
14 var c = content.substr(0, showChar);
15 var h = content.substr(showChar, content.length - showChar);
16
17 var html = c + '<span class="moreellipses">' + ellipsestext+ ' </span><span class="morecontent"><span>' + h + '</span> <a href="" class="morelink">' + moretext + '</a></span>';
18
19 $(this).html(html);
20 }
21
22 });
23
24 $(".morelink").click(function(){
25 if($(this).hasClass("less")) {
26 $(this).removeClass("less");
27 $(this).html(moretext);
28 } else {
29 $(this).addClass("less");
30 $(this).html(lesstext);
31 }
32 $(this).parent().prev().toggle();
33 $(this).prev().toggle();
34 return false;
35 });
36});