Populating Many checkboxes in tree structure inside Dropdown

柔情痞子 提交于 2019-12-11 16:50:31

问题


Guys Here is the checkboxes, where it displays in tree structure. I need it to be displayed inside the dropdown.

<html>

    <head>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

        <script type="text/javascript">

            $(document).ready(function(){

                $('.team').on('click',function(){
                    if($(this).is(':checked')){
                        $(this).next().next().show();
                    }else{
                        $(this).next().next().hide();
                    }
                });
            });


        </script>

    </head>

    <body>

        <form name="FootballClubs">

            <input type="checkbox" class="team" value="RealMadrid"/>Real Madrid<br />
            <div style="padding:10px 10px 10px 15px;display:none;">     
                <input type="checkbox" class="player" value="CR"/>Cristiano Ronaldo<br />
                <input type="checkbox" class="player" value="SA"/>Shabi Alanso<br />
                <input type="checkbox" class="player" value="IC"/>Iker Casillias<br />
            </div>  
            <input type="checkbox" class="team" value="ManCity"/>Man City<br /> 
            <div style="padding:10px 10px 10px 15px;display:none;">
                <input type="checkbox" class="player" value="SA"/>Sergio Aguero<br />
                <input type="checkbox" class="player" value="SM"/>Super Mario<br />
            </div>
        </form>

    </body>

</html>

I am trying to populate inside a dropdown. Help me.

Thanks in Advance.!!


回答1:


Look at jquery UI widget and jSTree



来源:https://stackoverflow.com/questions/13100122/populating-many-checkboxes-in-tree-structure-inside-dropdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!