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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:00:09+00:00 2026-05-23T22:00:09+00:00

I have a list of definitions with a jquery show/hide effect and readmore button

  • 0

I have a list of definitions with a jquery show/hide effect and “readmore” button that changes to “close” once its open. I now need to put another button that references an anchor at the top of the screen for each description. When I tried editing the script to add the new link, the “return to top of page” button then becomes another “close” button. I am not versed enough in JS to edit this script to make it do what I need it to without some strange consequence. Any help is appreciated.

SCRIPT
    $(function(){
    var slideHeight = 36;

    $('.jswrap').each(function(){
        var defHeight = $(this).height();

        if(defHeight >= slideHeight){
            $(this).css({'height':slideHeight,'max-height': defHeight});
            $(this).after($('<div class="jsreadmore"><a href="#">Read More</a></div>'));
        }
    });

    $('.jsreadmore a').click(function(){
        var $targetSlide = $(this).parent().prev(),
            curHeight = $targetSlide.height(),
            defHeight = $targetSlide.css('max-height');

        if(curHeight == slideHeight){
            $targetSlide.animate({
                height: defHeight
            }, "normal");
            $targetSlide.next().children('a').html('Close');    
        }else{
            $targetSlide.animate({
                height: slideHeight
            }, "normal");
            $targetSlide.next().children('a').html('Read More');
        }
        return false;
    });

});

HTML

<div class="jscontainer">
            <h4><a id="onedefinition">Definition Text</a></h4>
            <div class="jswrap">
                 <p>content</p>
            <p>morecontent</p>
            </div></div>

CSS

.content_sub1 .jscontainer {margin:0 auto;}
.content_sub1 .jscontainer h2 {font-size:20px;color:#0087f1;}
.content_sub1 .jswrap {position:relative; padding:10px; overflow:hidden;}
.content_sub1 .jsgradient {width:100%;height:35px; position:absolute; bottom:0; left:0;}
.content_sub1 .jsreadmore {padding:5px; color:#333; text-align:right;}
.content_sub1 .jsreadmore a {padding-right:22px; font-weight:bold; font-size:12px; text-transform: uppercase; color:#c44;  font-family:arial, sans-serif;}
.content_sub1 .jsreadmore a:hover {color:#000;}

LINK

http://www.doctorhtiller.com/procedures.html

  • 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-23T22:00:11+00:00Added an answer on May 23, 2026 at 10:00 pm

    This is because you are manipulating ALL the anchors in your element with this:

    $targetSlide.next().children('a').html('Read More');
    

    and

    $targetSlide.next().children('a').html('Close');
    

    The children('a') code says “Let’s affect all anchors which are direct children of the next() element”. Since your “return to top of page” anchor is simply another anchor, it has its html turned into ‘Read More’ or ‘Close’ respectively. What you need to do is differentiate your anchor from the anchors created by the script. We can easily do this by adding a class to the original anchors.

    So, instead of just adding an <a href="#"> we need to spice it up. Change:

    $(this).after($('<div class="jsreadmore"><a href="#">Read More</a></div>'));
    

    to

    $(this).after($('<div class="jsreadmore"><a href="#" class="read_more_link">Read More</a></div>'));
    

    Now it’s much easier to reference that specific anchor element. Simply add the class to your selector code:

    $targetSlide.next().children('a.read_more_link').html('Read More');
    $targetSlide.next().children('a.read_more_link').html('Close');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have list of rows that user select and i want to delete them,
am trying to use the Jquery accordion to show a list of links generated
I have an HTML definition list, and I want to use jQuery to turn
I have an AJAX callback that returns a list of results that are written
I have a number of build definitions that get executed based upon a single
I have set up a circular linked list data structure that represents a word,
I have List I want to sort Desc by Priority, which is int and
i have list of images and on mouse over there is option box shows
I have list of words. I type in a word misspelled. Can I query
I have list of files which contain particular patterns, but those files have been

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.