Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
How to use jquery to set the dot and button symbols to be turned on when the text exceeds five lines?

I have encountered a problem. I hope that when the text is less than five lines, the V symbol of the button will disappear, and the function of clicking the text to expand is also canceled, but when the article content exceeds 5 lines, the button will be restored to be visible and the article can be expanded by clicking the article. There are many articles, but because I just learned the program, I don’t know how to complete this effect in practice. I hope I can provide a way for me to learn. Thank you for your help!

$('.show').click(function(){
  $(this).toggleClass('rotate'); // remove more button
  $('.content').toggleClass('show-all'); // add class .show-all for .content when clicked on more button
});

$('.content').click(function(){
  $(this).toggleClass('show-all');
})
.content {
  height: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 5;
}
.content.show-all{
  height:auto;
  overflow:visible;
  text-overflow: none
}
.more {
  text-align: center;
}
.show{
  text-decoration: none;
  color: #222;
  transform:rotate(0deg);
}

.rotate{
  transform: rotate(20deg)
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="demo">
  <p class="content">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Suscipit odit fugit debitis, quibusdam esse eius ullam odio cupiditate cumque nostrum asperiores libero, sapiente aliquid animi? Saepe eligendi doloremque possimus. Velit sunt earum aliquam debitis quos eum atque nemo eius, hic quas doloremque facere et voluptatibus voluptatum eaque corrupti impedit ipsum beatae incidunt sapiente aliquid animi? Saepe eligendi doloremque possimus. Velit sunt earum aliquam debitis quos eum atque nemo eius, hic quas doloremque facere et voluptatibus voluptatum eaque corrupti impedit ipsum beatae incidunt sapiente aliquid animi? Saepe eligendi doloremque possimus. Velit sunt earum aliquam debitis quos eum atque nemo eius, hic quas doloremque facere et voluptatibus voluptatum eaque corrupti impedit ipsum beatae incidunt 
  </p>
  
  <div class="more">
    <a href="javaScript:;" class="show">V</a>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!