$(document).on('click', '.tree label', function(e) {
$(this).next('ul').fadeToggle();
e.stopPropagation();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="tree">
<li class="has">
<label class="container">ROOT<span class="total">(12) </span>
<input type="checkbox" name="domain[]" value="ROOT">
<span class="checkmark"></span></label></ul>
<ul style="display: none;">
<li><label class="container">CHILD<input type="checkbox" name="subject[]" value="CHILD"><span class="checkmark"></span></label></li>
</ul></li>
</ul>
Whenever I click the initial label, it should trigger a fadeToggle
effect on the following ul
. However, the toggle happens too quickly, resulting in an automatic fade-out.
Could someone kindly advise on the root of this issue? Could it be related to the formatting of the HTML code?