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

193
Views
How to give toggle function to each li in Jquery?

I am trying to add toggle function to each li. My problem is, If I click on menu 1, then my class is added to all list. I tried but I am not able to add present list. Any one can help me?

 <li>
  <div class="menucontainer">
  <div class="expandli">Menu 1 <i class="fa fa-arrow-circle-left"></i></div>
  <div class="expandlist">
   
      <ul>
          <li>Home</li>
          <li></li>
      </ul>
  </div>
  </div>
  </li>

  <li>
  <div class="menucontainer">
  <div class="expandli">Menu 2 <i class="fa fa-arrow-circle-left"></i></div>
  <div class="expandlist">
   
      <ul>
          <li>About</li>
          <li></li>
      </ul>
  </div>
</div>
</li>

JQuery

$('.menucontainer').click(function(){
  
  $(this).find('.expandlist').toggle(function () {
   $('.menucontainer').toggleClass("my");
   $(".fa-arrow-circle-left").toggleClass("fa-arrow-circle-right");
  
  });
 
  });
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!