如何找到每个 ul>中的最后一个 li>(前端,html,css,jquery)

时间:2022-11-27 21:30:01

I have a menu with their own submenus too.

我有一个菜单也有自己的子菜单。

如何找到每个 ul>中的最后一个  li>(前端,html,css,jquery)

Problem: When the page is loaded, the website emits a letter S at the end of every submenu.
How can i remove that letter S at the end of every submenu via JQuery or CSS?

问题:页面加载后,网站会在每个子菜单的末尾发出一个字母S.如何通过JQuery或CSS删除每个子菜单末尾的字母S?

This is the current markup when I copy html node in firebug:

这是我在firebug中复制html节点时的当前标记:

<nav class="shopMenuHover">
    <div id="bx_incl_area_5_1"> 
        <ul> 
            <li class=""><a href="#" class="firstLevel"><font><font>Main Menu 1</font></font></a>
            <div class="shopSubmenuHover" style=""><h2><a href="#"><font><font>Sub Menu 1</font></font></a></h2>
                <ul> 
                    <li>
                        <a href=""><font><font>Sub Menu &gt; Sub Menu</font></font></a>
                    </li>

                    <li><a href="">Sub Menu &gt; Sub Menu</a> s</li>
                </ul>
            </div>
        </li>


        <li class="firstLevel hasSubmenu instrumentarium-en-fresen">
        <a href="#" class="firstLevel"><font><font class="">Main Menu 2</font></font></a>

        <div class="shopSubmenuHover" style=""><h2><a href=""><font><font class="">Sub Menu 2</font></font></a></h2>
            <ul>
                <li><a href=""><font><font>Sub Menu &gt; Sub Menu</font></font></a></li>
                <li><a href="">Sub Menu &gt; Sub Menu</a> s</li>
            </ul>

        </div>
        </li>

            <li style="display:none " class="firstLevel hasSubmenu emptySubmenu outlet">
                                        <a href="#" class="firstLevel">Outlet<</a>

            </li>
        </ul>
    </div>
</nav>

This is the jquery that i used to find the last li of every ul

这是我用来找到每个ul的最后一个li的jquery

<script type="text/javascript">
  $(document).ready(function() {
     $('.shopMenuHover ul li:last-child').css( "border", "1px solid" );
  });
</script>

Kindly Please help me...

请帮帮我...

1 个解决方案

#1


0  

Use this one

使用这一个

<script type="text/javascript">

  $(document).ready(function() {
     $('.shopMenuHover ul li:last-child').contents(':not(a)').remove();
  });

</script>

#1


0  

Use this one

使用这一个

<script type="text/javascript">

  $(document).ready(function() {
     $('.shopMenuHover ul li:last-child').contents(':not(a)').remove();
  });

</script>