javascript - How to Collapsed all menu item -


i want collapsed menu item.

i have menu (that added later using jquery)

 <ul class="cd-accordion-menu animated">     <li class="has-children">         <input type="checkbox" name ="group-1" id="group-1" checked>         <label for="group-1">group 1</label>          <ul id="ulm">             <li class="has-children">                 <input type="checkbox" name ="sub-group-1" id="sub-group-1" checked>                 <label for="sub-group-1">sub group 1</label>                  <ul id="ulm">                     <li><a href="#0">image</a></li>                     <li><a href="#0">image</a></li>                 </ul>             </li>                            <li><a href="#0">image</a></li>             <li><a href="#0">image</a></li>         </ul>     </li> </ul> 

and

i using jquery

<a id="go" href="#">collapsed</a>  <script>     $(document).ready(function () {         $('#go').click(function () {             $('#ulm').css('display', 'none');         });     }); </script> 

but menu not collapsed

it link articles https://codyhouse.co/gem/css-multi-level-accordion-menu/

if u want collapse menu , u should hidden(display:none) children element of unchecked element.

<script> function menucollapsed() {      document.getelementsbytagname("input")[0].removeattribute("checked");;      document.getelementsbytagname("ul")[1].style="display:none"; } </script> 

use jquery simple.

your ajax means jquery?


Comments