---
title: "Create Read More / Read Less function via jQuery"  
description: "Create Read More / Read Less function via jQuery"  
author: "Ethan Karla"  
published: 2021-07-28  
updated: 2023-11-26  
canonical: https://www.mindstick.com/forum/156645/create-read-more-read-less-function-via-jquery  
category: "jquery"  
tags: ["jquery"]  
reading_time: 2 minutes  

---

# Create Read More / Read Less function via jQuery

How to create Read More / Read Less [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) via jQuery?

## Replies

### Reply by Aryan Kumar

Creating a "Read More" / "Read Less" functionality with jQuery involves toggling the visibility of content based on user interactions. Below is an example of how you can implement a simple "Read More" / "Read Less" feature:

```plaintext
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Read More / Read Less with jQuery</title>
  <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
  <style>
    .content {
      max-height: 100px; /* Set a max height for the content */
      overflow: hidden;
      transition: max-height 0.3s ease-out; /* Add a smooth transition effect */
    }

    .read-more {
      cursor: pointer;
      color: blue;
    }
  </style>
</head>
<body>

<div class="content">
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque varius nisl ac mauris
    ultrices, vel varius justo fermentum. Integer in dui sit amet nulla efficitur vestibulum.
    Suspendisse sed lectus vel arcu cursus volutpat.
  </p>
</div>

<div class="read-more">Read More</div>

<script>
  $(document).ready(function() {
    var content = $('.content');
    var readMoreButton = $('.read-more');

    readMoreButton.on('click', function() {
      content.toggleClass('expanded'); // Toggle the 'expanded' class
      var isExpanded = content.hasClass('expanded');

      // Adjust the text of the button based on the content state
      readMoreButton.text(isExpanded ? 'Read Less' : 'Read More');
      content.css('max-height', isExpanded ? 'none' : '100px'); // Set max-height accordingly
    });
  });
</script>

</body>
</html>
```

In this example:

- The content is initially limited to a maximum height, and the overflow is hidden.
- The "Read More" button toggles the visibility of the content by adding or removing the **expanded** class.
- The **max-height** property is adjusted with a smooth transition effect to create the "Read More" / "Read Less" animation.
- You can customize the **max-height** value and styling to fit the design of your website.

This is a basic example, and you might need to adapt it based on the structure and requirements of your specific project.


---

Original Source: https://www.mindstick.com/forum/156645/create-read-more-read-less-function-via-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
