I'm trying to make a function that ellipsis the text, given a number of max letters.
I got an array with all the text of the classes, already formated the way i want. The problem is that i need to change the text() of every class with the text that is in the array.
Here is my code:
var array = $('.elipse').map(function(){
return $(this).text();
}).get();
var i;
var teste = [];
for (i=0;i<array.length;i++){
if (array[i].length > 30){
teste.push(array[i].substr(0,10));
} else {
teste.push(array[i]);
}
}
for (var i=0;i<teste.length;i++){
$('.elipse').each(function(){
$(this).text(teste[i]);
});
}
The problem is in the last for loop. Every text of every element that contains the elipse class must be changed to the text in teste array. I tried to loop it in a lot of different ways, but im missing something