KristinaBalciu Posted October 8 Posted October 8 Site URL: https://bulldog-smilodon-7pdr.squarespace.com/services Is there a way to only show the first paragraph of a testimonial slider and add a "show more" button that would trigger showing the rest of the text? Right now it's such a massive amount of text that takes up the entire screen.
SameerSehra Posted October 9 Posted October 9 Yes, you can definitely achieve this with a bit of JavaScript and CSS. Here’s a simple approach: HTML Structure: Wrap your testimonial content in a <div> and include a "show more" button<div class="testimonial"> <p class="testimonial-text">This is the first paragraph of the testimonial. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <p class="testimonial-more" style="display: none;">This is the rest of the testimonial that will be hidden initially.</p> <button class="show-more-btn">Show More</button> </div> CSS: Style the testimonial as needed. The hidden text is controlled by the display property. .testimonial { margin: 20px; padding: 10px; border: 1px solid #ccc; } This will ensure that only the first paragraph is visible initially, with a button to reveal or hide the rest. You can adapt this code to fit your website's design. If you're looking for more advanced solutions or implementation, feel free to check out resources on my site www.itcrew.in for web development insights! KristinaBalciu 1
tuanphan Posted October 11 Posted October 11 You try this code to Website Tools > Code Injection > Footer <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function() { const $textElement = $(".list-item-content__title"); const tpfullText = $textElement.text().trim(); const maxLength = 300; if (tpfullText.length > maxLength) { const truncatedText = tpfullText.substring(0, maxLength) + "..."; $textElement.text(truncatedText); $textElement.after('<a href="#" class="show-more">Show more</a>'); $(".show-more").on("click", function(e) { e.preventDefault(); $textElement.text(tpfullText); $(this).remove(); }); } }); </script> <style> a.show-more { display: block; text-align: center; margin-top: 10px; } </style> Result and when click show more KristinaBalciu 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment