jQuery for Characters Limit

If your want to limit characters, you can use this jQuery.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s.

[code lang=”js”]<script>
jQuery(document).ready(function(){
jQuery("#mydiv").each(function() {
var title_text=jQuery(this).text();
var dots = "…";
if(title_text.length &gt; 35)
{
title_text = title_text.substring(0,35) + dots;
}
jQuery(this).html(title_text);
});
});
</script>[/code]

Result: Lorem Ipsum is simply dummy text of…

Leave a Reply

Your email address will not be published. Required fields are marked *