douyuan9512 2013-12-19 11:46
浏览 20
已采纳

如果找不到子<> ul <li>,则删除父<li>

i am generating menu dynamically using php in my project in ul li. menu are generating as follows.

<ul id="css3menu1" class="topmenu">
    <li class="toproot"><a href="#"><i class="user"><span>User</span></i></a>
        <ul>
           <li><a href="some link">Create User</a></li>
           <li><a href="some link">List User</a></li>
        </ul>
    </li>

   <li class="toproot"><a href="#"><i class="user"><span>Group</span></i></a>
        <ul>
            <li><a href="some link">Create Group</a></li>
            <li><a href="some link">Group List</a></li>
        </ul>    
    </li>

     <li class="toproot"><a href="#"><i class="user"><span>Settings</span></i></a>
        <ul>
            <!--links are not generated here -->
        </ul>    
    </li>                   

</ul>

now the problem is that i want to remove third li of setting main menu beacause of it has no submenu. i searching for jquery code for this implementation. i have use php to display or display not main menu. but want to implement in jquery/js. thanks in advance

  • 写回答

2条回答 默认 最新

  • donglan8870 2013-12-19 11:47
    关注

    Try

    $('.topmenu li.toproot:not(:has(ul))').remove()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)