Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var showTotalChar = 50, showChar = "Show more..", hideChar = "show less..";
- $('div.show').each(function() {
- var content = $(this).text();
- if (content.length > showTotalChar) {
- var con = content.substr(0, showTotalChar);
- var hcon = content.substr(showTotalChar, content.length - showTotalChar);
- var txt= con + '<span class="dots">...</span><span class="morectnt"><span>' + hcon + '</span> <a href="" class="showmoretxt">' + showChar + '</a></span>';
- $(this).html(txt);
- }
- });
- $(".showmoretxt").click(function() {
- if ($(this).hasClass("sample")) {
- $(this).removeClass("sample");
- $(this).text(showChar);
- } else {
- $(this).addClass("sample");
- $(this).text(hideChar);
- }
- $(this).parent().prev().toggle();
- $(this).prev().toggle();
- return false;
- });
Add Comment
Please, Sign In to add comment