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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:36:34+00:00 2026-06-08T01:36:34+00:00

Could you please help me with this code? I was looking for an asnwer

  • 0

Could you please help me with this code? I was looking for an asnwer here but its a bit hard for me as I’m a beginner in jquery programming. What I’m trying to do here is to REPLACE the (‘read more…’) text after it’s pressed with (‘read less…’) for example. I was trying to do it but it fails over and over again. I found other posts here about this, but I would like to use the script I made to train more with this. Any thoughts?
the code is here.

$(document).ready(function(){
var $posts = $('#items > div');
var maxHeight = 95;

$('a', $posts).live('click', function(){
    var $par = $(this).prev('p');

    var oH = parseInt($par.attr('class'));

    if($par.height() == oH){
        $par.animate({
            'height': maxHeight
        }, 'medium');
    }else{
        $par.animate({
            'height': oH
        }, 'medium');
    }
});

$posts.each(function(){
    if($('p', this).height() > maxHeight){

        $('p', this)
            .attr('class', $('p', this).height())
            .css('height', maxHeight+'px');
        $(this).append($('<a>').text('read more...'));
    }
});

});

What sort of code and where should I place to replace the ‘read more…’ with ‘read less’ after ‘read more…’ is pressed (it expands – animate down). Apart of replacing the text the script is working fine.. thank you for any help given. I’ll kindly appreciate all tips. Thank you in advance

  • 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-08T01:36:37+00:00Added an answer on June 8, 2026 at 1:36 am

    You can change the link text by calling $(this).text('....');

    if($par.height() == oH){
        $par.animate({
            'height': maxHeight
        }, 'medium');
        $(this).text('read more...');
    }else{
        $par.animate({
            'height': oH
        }, 'medium');
        $(this).text('read less...');
    }
    

    Here is a demo

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

Sidebar

Related Questions

Could anyone please help me convert this code to vb.net, I have tried it
Could you please help me converting this c++ code into python: I am trying
Could someone please help me in here, I'm just a beginner who want to
Could someone please help me to convert this String into a Map ... String
Could someone please help explain why I can't get this to work? I properly
Could anyone give me some help with this please? The content needs to appear
I've been looking at this code: http://www.jquery4u.com/jquery-date-and-time-2/online-jquery-stopwatch/ I'm trying to understand exactly how it
I'm not looking for any specific code examples, but could someone explain why I
Could you please help me out to find the correct deceleration rate for the
Could you please help me to get image upload working on a view with

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.