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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:49:27+00:00 2026-06-05T13:49:27+00:00

Seem more..issue (Operation slows down after clicking see more 5-10 times) Ive modified See

  • 0

Seem more..issue (Operation slows down after clicking see more 5-10 times)

Ive modified See More.. technique based on code over here http://jsfiddle.net/hgxbf/
The issue what im facing is after clicking of See More/See Less 5-10 times the operation becomes really slow and does not expand/collapse properly.

       <div class="seeMore" />  

is dynamically added by the script

HTML Structure.

<div class="Blk">
    <div class="Title">
        Donec at elit sed metus placerat placerat congue ut purus
    </div>
    <p class="trunc">
                                    Proin ipsum lectus, facilisis sed ornare eget, egestas vel mi. Nullam ac odio arcu. Nunc congue, urna vitae malesuada consequat, leo erat bibendum nunc, et fringilla nibh diam ac tellus. Sed quis ante a ipsum placerat fermentum. Aliquam erat volutpat. Praesent rutrum ornare lectus tincidunt suscipit.
    </p>
    <div class="seeMore">
        <span>SEE MORE</span>
    </div>                          
</div>

My Code http://jsfiddle.net/y4GXL/1/

Any help really appriciated!

  • 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-05T13:49:29+00:00Added an answer on June 5, 2026 at 1:49 pm

    I had some spare time, so I’ve fixed it up for you.

    Basically you have to keep one reference to the “see more / see less” element and keep a state variable. Inside the click handler you decide to take action depending on the state; collapse or expand. After every state change, you update the “button” text and state.

    I’ve also applied more convenient variable naming (all jquery elements are prefixed with a dollar) and made the top function return the result of .each; otherwise the jQuery chain is broken.

    (function($) {
        $.fn.truncateText = function(maxWords) {
            return this.each(function() {
                var $el = $(this),
                origText = $el.text(),
                truncText = origText.split(' '),
                state,
                $toggleButton;
    
                // decide whether to place a button    
                if (truncText.length <= maxWords) {
                    return;
                }
    
                truncText.length = maxWords;
                truncText = truncText.join(' ');
    
                // add button and define click handler    
                $toggleButton = $('<div class="seeMore"></div>')
                    .insertAfter($el)
                    .on('click', function() {
                        if ('open' == state) {
                            collapse(); // old state was open, so close it
                        } else {
                            expand(); // old state was closed, so open it
                        }
                    });
    
                function collapse()
                {
                    $el.text(truncText + ' ...');
                    state = 'closed';
                    $toggleButton.text('See More');
                }
    
                function expand()
                {
                    $el.text(origText);
                    state = 'open';
                    $toggleButton.text('See Less');
                }
    
                collapse();
            });
        }
    })(jQuery);
    $(".trunc").truncateText(4);​
    

    In action here: http://jsfiddle.net/y4GXL/6/

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

Sidebar

Related Questions

This may seem a little more complex than you first thought when clicking on
More often than I'd have hoped I seem to come across method/property definitions in
This is a lot more complicated than it might seem at first. What I
I seem to be missing something obvious here, why would I want more than
So this may seem like a widely-answered question, but I'm interested more in the
Why do Scalar-valued functions seem to cause queries to run cumulatively slower the more
So this is more of a generic question. I seem to keep finding myself
I seem to have some weird issue going on that I am sure will
I seem to be having an issue with Jax-WS and Jax-b playing nicely together.
I seem to run into a couple of design issue a lot and I

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.