Limit string length/trim text with jQuery


/ Published in: jQuery
Save to your folder(s)

Limit string length/trim text with jQuery


Copy this code and paste it in your HTML
  1. jQuery(document).ready(function($){
  2. $("h3").each(function(){
  3. if ($(this).text().length > 30) {
  4. $(this).text($(this).text().substr(0, 27));
  5. $(this).append('...');
  6. }
  7. });
  8. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.