I want to reduce every sentence which has more than 3 letters, my code is showing the first 3 letters, then it adds "...", by clicking on these "..." I want to show the whole sentence. But when I'm clicking on every single "..." it reveals every sentence instead of the very sentence I clicked on.
My code is:
$('.test').each(function(){
var el = $(this);
var textOri = el.html();
if(textOri.length > 3){
el.html(textOri.substring(0,3)+'<span class="more">...</span>');
}
$(document).on('click', el.find('.more'), function() {
el.html(textOri);
});
});
here a jsFiddle: http://jsfiddle.net/malamine_kebe/GxDsJ/