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

250
Views
Cómo desmarcar la casilla de verificación secundaria al hacer clic en la casilla de verificación principal

Hola, necesito marcar y desmarcar las casillas de verificación secundarias al hacer clic en las casillas de verificación principales. En este momento, puedo marcar las casillas de verificación secundarias pero no puedo desmarcarlas haciendo clic en el mismo, cómo lograr esto.

mi código

HTML

 <ul class="theme-list-p"> <li> <input type="checkbox" name="">&nbsp;&nbsp;Ambah <ul class="theme-list-c"> <li><input type="checkbox" name="">&nbsp;&nbsp;Kirnapur</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Barwani</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Sihora</li> </ul> </li> <li><input type="checkbox" name="">&nbsp;&nbsp;Sabalgarh <ul class="theme-list-c"> <li><input type="checkbox" name="">&nbsp;&nbsp;Village1</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Village2</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Village3</li> </ul> </li> <li><input type="checkbox" name="">&nbsp;&nbsp;Kailaras</li> </ul>

CSS

.tema-lista-p{

 list-style: none; padding-left: 10px; font-weight: bold; border:1px solid #dee2e6; padding: 5px; overflow-y: scroll; min-height: 120px; } .theme-list-c{ list-style: none; padding-left: 20px; font-weight: 400; }

jquery

 <script type="text/javascript"> $(document).on('change', '.theme-list-p li', function(){ $(this).find('.theme-list-c li input').attr('checked', true); }); </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Podrías hacerlo así:

 $(document).on('change', '.theme-list-p li input', function() { $(this).next('.theme-list-c').find('li input').attr('checked', $(this).is(":checked")); });

Manifestación

 $(document).on('change', '.theme-list-p li input', function() { $(this).next('.theme-list-c').find('li input').attr('checked', $(this).is(":checked")); });
 .theme-list-p { list-style: none; padding-left: 10px; font-weight: bold; border: 1px solid #dee2e6; padding: 5px; overflow-y: scroll; min-height: 120px; } .theme-list-c { list-style: none; padding-left: 20px; font-weight: 400; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <ul class="theme-list-p"> <li> <input type="checkbox" name="">&nbsp;&nbsp;Ambah <ul class="theme-list-c"> <li><input type="checkbox" name="">&nbsp;&nbsp;Kirnapur</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Barwani</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Sihora</li> </ul> </li> <li><input type="checkbox" name="">&nbsp;&nbsp;Sabalgarh <ul class="theme-list-c"> <li><input type="checkbox" name="">&nbsp;&nbsp;Village1</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Village2</li> <li><input type="checkbox" name="">&nbsp;&nbsp;Village3</li> </ul> </li> <li><input type="checkbox" name="">&nbsp;&nbsp;Kailaras</li> </ul>

about 4 years ago · Juan Pablo Isaza Report
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!