Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4059420
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:12:24+00:00 2026-05-20T15:12:24+00:00

I know there are lots of truncate scripts out there, but I can’t use

  • 0

I know there are lots of truncate scripts out there, but I can’t use most of them due to integration issues with the cms I am working on.

Basically I must do it this way:

  1. get a count of the characters inside a div
  2. if count exceeds a certain amount (lets say 10 characters) the text inside the div should be cut off and have “…” appended to the end.

Being terrible at javascript here is my lame non-working attempt:

if ($('div.text').val().length > 10) {

   //     

   ($('div.text').append('...');

}

Can someone please help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:12:24+00:00Added an answer on May 20, 2026 at 3:12 pm
    if ($('div.text').text().length > 10)
    

    or

    if ($('div.text').html().length > 10)
    

    div elements don’t have a “value” as returned by val(), but they do have text or html

    and then you probably want to truncate the text like

    var text = $('div.text').text();
    text = text.substr(0,10) + '...';
    $('div.text').text(text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are lots of examples out there on this, but they
I know there are lots of similar questions out there like this, but all
I know there are lots of FF/Chrome CSS questions, but I can't seem to
I know there are lots of delegate/func examples but I can't find any examples
hey, i know there's lots of tutorials out there but none seem to be
I know there are lots of tools on the net that can make our
I know there is a lot on this topic but I can't get any
I know there are lots of posts similar to this, but after crawling SO,
I know there are lots of methods already given in stackoverflow but in my
I know there are lots of question like this. But I don't want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.