jQuery - Read More Read Less How to replace text

0 votes

HTML:

<a href="#" class="show_hide" data-content="toggle-text">Read More</a>

jQuery:

// Slide Up Slide Down
$('.show_hide').toggle(function(){
$(this).text().replace("Read More", "Read Less");
$('.' + $(this).attr('data-content')).slideDown();

},function(){
$(this).text().replace("Read Less", "Read More");
$('.' + $(this).attr('data-content')).slideUp();
});

I am trying to make one of those "Read More / Read Less" buttons to hide and show text.
How do I replace "Read More" with "Read Less" on click?

Your input is much appreciated!

Jul 1, 2022 in Web Development by gaurav
• 23,260 points
1,718 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
0 answers

How to disabled or non-editable text editor using CSS or jQuery?

I am using a rich text editor on my ...READ MORE

Aug 18, 2022 in Web Development by gaurav
• 23,260 points
1,000 views
0 votes
0 answers

Javascript/Jquery - how to replace a word but only when not part of another word?

I am currently doing a regex comparison ...READ MORE

Aug 22, 2022 in Web Development by gaurav
• 23,260 points
695 views
0 votes
1 answer

How to replace html element with ajax response?

Hello @kartik, Assuming you are replacing your products, ...READ MORE

answered Jul 8, 2020 in Web Development by Niroj
• 82,840 points
10,611 views
0 votes
1 answer

How to download a file by jQuery.Ajax?

Hello @kartik, You don't need to do this ...READ MORE

answered Sep 18, 2020 in Web Development by Niroj
• 82,840 points
7,527 views
0 votes
1 answer

How to place images using jQuery masonry plugin to start

You were just missing a css class that adjusts ...READ MORE

answered Jun 22, 2022 in Web Development by rajatha
• 7,680 points
575 views
0 votes
1 answer

How to use JQuery with ReactJS

Yes, we can use jQuery in ReactJs. ...READ MORE

answered Jun 22, 2022 in Web Development by rajatha
• 7,680 points

edited Dec 15, 2023 by Soumya 14,762 views
0 votes
0 answers

jQuery slideUp div if already slided down?

I have a simple question about jquery ...READ MORE

Aug 24, 2022 in Web Development by gaurav
• 23,260 points
737 views
0 votes
1 answer

jQuery slideDown() animation not working

Your p element is already displayed when you enter ...READ MORE

answered Jun 16, 2022 in JQuery by rajatha
• 7,680 points
1,468 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,352 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
15,884 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP