Vote count:
0
Hi I have the Following <h2> "Example example example example". I want to detect the lenght of this <h2> and if it's less than 10 characters, shrink it to "Example ex...". Get it? Shrink it to 10 characters long and add "..." to the end.
Here's my code:
HTML
<h2>Example example example example example</h2>
<h2>Example</h2>
jQUERY
$(document).ready(function(){
var dtl = $('.h2').text().length;
if(dtl>10){
$('.h2').text().length = 10;
$('.h2').text($('.h2').text()+"...");
}
});
But that's not working...
asked 1 min ago
Shrink a text if less than 10 characters lenght
Aucun commentaire:
Enregistrer un commentaire