jquery expanding read more link

How we can create a read more button to expand and collapse any section? Solution: See this jQuery Expanding Read More Link With CSS, Read More Button Expand.

Previously I have shared some expandable programs, but this is a read more or load more button to show full content. Basically, when we have many texts in a section and we want to fit it on the webpage then we use read more extension. The read more button help to hide overlap texts or elements and on the click, it expands and shows all the contents.

Today you will learn to create Read More Button Expand function. Basically, there are 3 sections with a heading, some dummy text, and a read more button. At first or by default its has a height value and hides all overflow texts and when you will click on the button the section to expand and show all texts. When all section expands then the read more text will replace by ‘read less‘ and on clicking it the section will collapse or decrease again. Also, there is an arrow button that changes up and down according to the condition.

So, Today I am sharing jQuery Expanding Read More Link With CSS. There I have used HTML to create the layout, CSS for styling, and jQuery for functioning. As we know jQuery is a JavaScript library, it saves time and effort. This program can be used for text and other elements also like, you can use it on posts. If you want to show XX quantity of post and other will visible on a load more button click. You can use this program on your website after some modifications.

If you are thinking now how this read more link program actually is, then see the preview given below.

Preview Of Read More Button Expand

See this video preview to getting an idea of how this expanding program looks like.

Live Demo

Now you can see this program visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.

jQuery Expanding Read More Link Source Code

Before sharing source code, let’s talk about it. First I have created the main div named ‘container’ and placed all the elements inside it.  Inside the main div, I have placed 3 div sections because there are 3 cards. All the cards are same, these contain the same text and same class name copy-pasted. I have created a div with multiple class names, and placed a heading tag and texts inside it.

Now using CSS I have placed all the items in the right place, as you can see in the preview. With CSS first I gave basic values like size, position, margin, padding, etc to the elements. There I have used Unicode icons in CSS content command for showing the icons. Also, there I have color values to the button and texts.

jQuery handling here the main feature expand and collapse in this program. There I have stored values like ‘Read More‘, ‘Read Less‘ and animation duration in variables. Now I have created multiple functions for different conditions like open or close. Left all other things you will understand after getting the codes, I can’t explain all in writing.

For creating this program you have to create 3 files. First file for HTML, second for CSS, and third for JavaScript. Follow the steps to creating this program without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes given here.

function.js

The final step, create a JavaScript file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created jQuery Expanding Read More Link With CSS, Read More Button Expand. If you have any doubt or question comment down below.

Thanks For Visiting, Keep Visiting.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here