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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:29:45+00:00 2026-06-14T09:29:45+00:00

When clicking a button I would like the text to toggle and say read

  • 0

When clicking a button I would like the text to toggle and say “read more” or “read less”. If I click an other button, I would like the previous button go back to its original text “read more”

HTML:

  <div class="accordion">
  <div class="abtn">
    <input id="A-1" type="radio" value="A">
    <label class="chars" for="A-1">A</label>
    <div class="char-more">Learn More</div>
 </div>
<div class="acontent">Hello I am content A</div>

 <div class="abtn">
     <input id="B-1" type="radio" value="B">
     <label class="chars" for="B-1">B</label>
     <div class="char-more">Learn More</div>
 </div>
 <div class="acontent">Hello I am content B</div>

 <div class="abtn">
     <input id="C-1" type="radio" value="C">
     <label class="chars" for="C-1">C</label>
     <div class="char-more">Learn More</div>
   </div>
    <div class="acontent">Hello I am content B</div>
</div>

jQuery:

   $(".abtn .char-more").click(function(){
       $(this).closest('.abtn').nextAll(".acontent").first().slideToggle("fast")
       .siblings(".acontent:visible").slideUp('fast');
       $(this).html("Read Less");
       $(this).siblings(".char-more").html("Read More");
   });

JsFiddle.

  • 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-14T09:29:47+00:00Added an answer on June 14, 2026 at 9:29 am

    Using following html structure and adding an active class to each module you can simplify how you find the previous module activated( if there is one) and also add a little style using css. It’s also a little more intuitive to read than trying to debug siblings that don’t exist and nestaAll‘s

    <div class="widgetWrap">
        <div class="abtn">
            <input id="A-1" type="radio" value="A">
            <label class="chars" for="A-1">A</label>
            <div class="char-more">Learn More</div>
         </div>
         <div class="acontent">Hello I am content A</div>
    </div>
    

    Your code would follow a pattern like:

    $('.char-more').click(function(){ 
          var $prevActive=$('.activeClass');
         $prevActive.removeClass('activeClass').find('.char-more').text("Read Less");
         $prevActive.find('.acontent').slideUp(); 
         $(this).text("Read Less")
                 .closest('.widgetWrap').addClass('activeClass').find('.acontent').slideDown(); 
    
    })   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mvc3 Ajax.BeginForm. Instead of clicking on the button I would like
I am working on an android 2.2 app. When clicking a button I would
I inserted a dateField component. On clicking, it displays calendar. I would like to
I have a text like <AnyTag>here is a sample test text and more text</AnyTag>.
I would like to hide a div when a button is clicked and show
I have a PyQt4.9 window where I would like to toggle the translucency on
I would like to develop a way for sending text messages (SMS) from Microsoft
I use watir for testing in RadRails IDE.After clicking button Delete appears window Message
On clicking a button, I want the selected rows to be inverted (non-selected rows
Iam in parent view while clicking the button in the parent view I want

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.