我如何找到最后一个<li></li>在每个 <ul></ul>(前端,html,css,jquery)

2022-01-19 00:00:00 frontend jquery javascript html css

我也有一个带有自己子菜单的菜单.

I have a menu with their own submenus too.

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

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?

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

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

<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>

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

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

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

请帮帮我...

推荐答案

用这个

<script type="text/javascript">

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

</script>

相关文章