Limit string length | trim text with jQuery | trim() in jquery

Assume we have header and its bit too long and we need to trim it using jquery. Wondering what to do. below is the code which helps to trim the string using jquery

My big header goes here bla bla bla bla bla bla bla bla bla bla lorem ipsum lorem


if ($('#trimHolder h2').length > 20 ) {
         // trims it to 17 charcters
           // 17 charcters + .......


I Am suresh(suresh kumar )a Web developer,Freelancer,webdesigner,UI developer from bangalore. Got 6+ yrs of IT experience . I specialize in standards-based XHTML, CSS and JavaScript web development. Each site I develop is built to be search engine friendly (SEO), using the latest development principles and techniques.

You may also like...

2 Responses

  1. Ariel says:

    Thanks for the post.
    Best Regards

  2. Senling says:

    Thanks for the tips. It helped me at the right time.
    All the best.

Leave a Reply

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