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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:12:47+00:00 2026-06-15T21:12:47+00:00

Used and modified the code below. Works exactly the way I need it too,

  • 0

Used and modified the code below. Works exactly the way I need it too, but when I use it multiple times on the same page it opens all of my excerpts at the same time. Does anyone know why, and what I need to do for it to stop and open only on the items that have been clicked?

HTML:

<article class="excerpt">
   <h2>Title</h2>
   <p>This is a sentence...</p>
   <div class="full-story">
      <p>This is the rest of the first sentence...</p>
   </div>
   <a class="excerpt-trigger" href="#">Read More</a>
</article>

jQuery:

$('.full-story').hide();

$('.excerpt-trigger').toggle(function() {
  $('.full-story').fadeIn('slow');
  $(".excerpt-trigger").removeClass("is-more");
  $(".excerpt-trigger").addClass("is-less");
  $(this).text("Less info");
}, function() {
  $('.full-story').hide('fast');
  $(".excerpt-trigger").addClass("is-more");
  $(".excerpt-trigger").removeClass("is-less");
  $(this).text("More info");
});

Sorry, left out the excerpt-trigger class. Updated.

  • 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-15T21:12:48+00:00Added an answer on June 15, 2026 at 9:12 pm

    A selector such as $('.full-story') will select all elements that has the class full-story. What you want is to reference the current element being clicked on by using $(this), and then selecting the very next full-story using .next('.full-story'). You can selected its children by using .children(), and a previous element using .prev().

    In your case, it should go like this:

    $('.excerpt-trigger').toggle(function() {
        var ref = $(this); // Caching is good.
        ref.prev('.full-story').fadeIn('slow');
       ref.removeClass("is-more").addClass("is-less").text("Less info");
    }, function() {
        var ref = $(this);
        ref.prev('.full-story').hide('fast');
        ref.addClass("is-more").removeClass("is-less").text("More info");
    });
    

    Here is the documentation on .next(), .children() and .prev().

    Additionally, you might want to prevent the event from bubbling when you click your <a>, so that the href="#" instruction is not carried over. Check out event.preventDefault();

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

Sidebar

Related Questions

if a style is used, it can not be modified agaign. so i need
Used code I found on SO to use the COM based Acrobat Reader to
I am trying to scrap some content from a website but the code below
EDIT4: I don't know why, but the structure I used below didn't work. I
I've a got a code snippet below modified from http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.aspx : public class WebPartBla
I used below code for free hand drawing on the whole view: UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image
I used Jquery to insert a variable to div. Please check my code. var
i used bellow code to search and find if http is includes in $url
With the following code below I have managed to open an Access.mpd database and
I have modified the tpl used for the grid view to show 3 columns

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.