jquery - Truncate paragraph except image to show/hide rest with View more link -
hi newbie injavascript/jquery need help. have class including text , image. want in case text more 70 characters rest of hidden except image .moreover want @ end of truncated text see link view more on click expand full text.when text expanded link should become less doing opposite .im trying slidetoggle because seems smoother..
this tried di not manage either keep images or make view more link functional. assistance appreciated :
var minimized_elements = $('.child_body').contents(':not(img)'); minimized_elements.each(function(){ var t = $(this).text(); if(t.length < 70) return; $(this).html(t.slice(0,70)+'<span>...</span><a href="#" class="more">view more</a>'); $("a.more").click(function(){ $("minimized_elements").slidetoggle(); }); });
Comments
Post a Comment