如何删除jQuery选择的最后一个元素?

栏目: jQuery · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/2735891/how-to-remove-the-last-element-of-a-jquery-selection
我使用 jquery

选择器:

$('#menus>ul>li>a')

我想在没有最后一个的情况下迭代选择器结果:

$('#menus>ul>li>a').removeLast().each(fct());

当然函数“removeLast()”不存在,是否有等价的?

谢谢.

您可以使用:not selector或.not()方法:

$('#menus>ul>li>a:not(:last)')

要么

$('#menus>ul>li>a').not(":last")

翻译自:https://stackoverflow.com/questions/2735891/how-to-remove-the-last-element-of-a-jquery-selection


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

JavaScript Patterns

JavaScript Patterns

Stoyan Stefanov / O'Reilly Media, Inc. / 2010-09-21 / USD 29.99

What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced d......一起来看看 《JavaScript Patterns》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具