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 7861713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:50:35+00:00 2026-06-02T22:50:35+00:00

i have a problem. i load some text from the db. On my page,

  • 0

i have a problem. i load some text from the db. On my page, i only want to show 30 first words of this text. I will then add a ‘read more’ button, which will redirect the user to a new page. So the ‘jquery expander plugin’, which will show the remaining text in the same div, will not work for me I think.

i got this far:

$content = $("#blog_1").find(".entryContent").text().split(" ");
$slicedContent = $content.slice(30);

I have been messing around with .split and .slice for hours. But no success.
I don’t even have to ‘keep’ the remainder of the text, since it will be loaded again when the user will click read more, on the ‘detail page’. So onwards from word 30, the text could be removed from the DOM.
answers regarding displaying a set number of characters instead of words are also helpful.

Thanks in advace!

  • 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-06-02T22:50:37+00:00Added an answer on June 2, 2026 at 10:50 pm

    To answer your question first, it’s like this:

    var test = "I have been messing around with .split and .slice for hours. But no success. I don't even have to 'keep' the remainder of the text, since it will be loaded again when the user will click read more, on the 'detail page'. So onwards from word 30, the text could be removed from the DOM. answers regarding displaying a set number of characters instead of words are also helpful."
    var splittest = test.split(' ')
    splittest.slice(0, 10)
    (returns ["I", "have", "been", "messing", "around", "with", ".split", "and", ".slice", "for"])
    

    I would not do this though. It’s better to limit on the amount of text instead, then there is less worry about having to detect word beginnings/endings. It will also make styling easier and more predictable.

    test.slice(0, 300)
    (returns "I have been messing around with .split and .slice for hours. But no success. I don't even have to 'keep' the remainder of the text, since it will be loaded again when the user will click read more, on the 'detail page'. So onwards from word 30, the text could be removed from the DOM. answers regardi")
    

    Better yet again is to limit the generation of this text server side. It’s just a plain wasted of bandwidth to send all that data down and not use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a this asp.net page which upon first time load: 1: Make a
I have some problem with my IIS today. I try to load a .img
Ok I have this problem I'm trying to use Jquery to load a partial
I have problem with $_POST data. Some fields are missing from input form when
I'm trying to do a loop where I load some content from another page
So I'm trying to load some returned html from an .aspx page but a
So i have a NivoSlider on my page. My problem is that i want
I have a problem using Linq to NHibernate to load an object and eagerly
I have a problem with out of memory when I'm trying load a few
I have a little problem with a Listview. I can load it with listview

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.