expand collapse unordered list

HTML:
   <ul class="list">
        <li>
            <a>Rifles</a>
            <ul>
                <li>M16</li>  
                <li>MP5</li>  
                <li>AR15</li>  
                <li>M16A1</li>            
            </ul>                
        </li>

        <li>
            <a>Guns</a>
            <ul>
                <li>Magnum</li>  
                <li>Colt</li>      
            </ul>                
        </li>
    </ul>
JS:
$('.list > li a').click(function() {
        $(this).parent().find('ul').toggle();
    });​

Comments

Popular posts from this blog

Easy Ui Jquery easyui-textbox change onChange event

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

npm install gets stuck at fetchMetadata