I have a string placed inside the tag and I wanted to truncate it and add an ellipsis at the end of the truncated string. I coded this using jquery and it seems my code doesn't work on my end.
here is my jquery code:
$(".link-content > h4").each(function(){
var len=$(this).text().lenght;
var str=$(this).text().substr(0,26);
var lastIndexOf=str.lastIndexOf();
if(len>26){
$(this).text(str.substring(0, lastIndexOf)+"...");
}
});
<div class="links">
<span>FACEBOOK</span>
<div class="link-content">
<h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Etiam lacus tellus, tristique congue pellentesque ac, semper eu
d iam.</h4>
</div>
</div>
.lenght;won't worklength, notlenght