@manhng

Welcome to my blog!

JavaScript Labs

January 20, 2018 09:49

JavaScript Labs

  • Lab1: Làm thế nào để sổ danh sách các mục con khi click vào mục cha hay click vào dấu (+)
  • Lab2: Làm thế nào để

Làm thế nào để sổ danh sách các mục con khi click vào mục cha hay click vào dấu (+)

  • javascript toggle
  • jquery toggle
  • bootstrap collapse

https://www.w3schools.com/bootstrap/bootstrap_collapse.asp

http://www.sendesignz.com/how-to-create-expand-and-collapse-list-item-using-jquery/

https://stackoverflow.com/questions/11798573/expand-collapse-unordered-list

http://jsfiddle.net/mtCWr/2/

    <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>
    $('.list > li a').click(function() {
        $(this).parent().find('ul').toggle();
    });​
 

Categories

Recent posts