js,jquery,toggle方法的点击切换

                <ul class="zj_tab2">
                    {foreach $category_list as $k=>$v}

                    <li {if $v['id']==48}id="sun_cate1" class="active" style=""{/if}>
<!--                    <a href="/index/index/{$v['actions']}/type/{$v['id']}">{$v['name']}</a>-->
<!--                    <a href="javascript:void(0)">{$v['name']}</a>-->
                    {$v['name']}{if $v['id']==48}&nbsp;>{/if}
                    {if $v['id']==48}
                        {if !empty($sun_category)}
                            <ul id="sun_cate" class="hid zj_tab2">
                                {volist name="sun_category" id="sun"}
                                <li>{$sun.name}</li>
                                {/volist}
                            </ul>
                        {/if}
                    {/if}
                    </li>
                    {/foreach}
                    <script>
                            $("#sun_cate1").on("click", function()
                            {
                                $("#sun_cate").toggle(
                                    function(){
                                        console.log('bbbbb');
                                        $(this).addClass("hid");
                                    },
                                    function(){
                                        console.log('aaaaa');
                                        $(this).removeClass("hid");
                                    }
                                )
                            })
                    </script>

发表评论

您的电子邮箱地址不会被公开。