当前位置:网站首页>jq怎么获取倒数的元素
jq怎么获取倒数的元素
2022-06-27 05:02:00 【前端切图仔Zz】
<ul>
<li>倒数第四个</li>
<li>倒数第三个</li>
<li>倒数第二个</li>
<li>倒数第一个</li>
</ul>
jq获取最后一个元素:
var text = $('ul li').last().text()
console.log(text)
打印结果:
jq获取倒数第二个元素:
var text = $('ul li').eq(-2).text()
console.log(text)
打印结果:
拓展:
eq() 方法 :返回带有被选元素的指定索引号的元素。
语法
$(selector).eq(index)
index 必需要有,用以规定元素的索引。可以是整数或负数。其中,使用负数将从被选元素的结尾开始计算索引。
边栏推荐
- Argo workflows - getting started with kubernetes' workflow engine
- 018 basics of C language: C file reading and writing
- EPICS记录参考5 -- 数组模拟输入记录Array Analog Input (aai)
- Kotlin compose implicitly passes the parameter compositionlocalprovider
- 第2章 关键技术介绍
- Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan
- three.js第一人称 相机前枪的跟随
- Matlab | visualization of mathematical properties related to three interesting circles
- Kotlin compose compositionlocalof and staticcompositionlocalof
- 流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)
猜你喜欢

Kotlin compose compositionlocalof and staticcompositionlocalof

真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......
![[BJDCTF2020]The mystery of ip](/img/f8/c3a7334252724635d42c8db3d1bbb0.png)
[BJDCTF2020]The mystery of ip

Deep dive kotlin synergy (XV): Test kotlin synergy

Microservice system design -- message caching service design

论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》

微服务系统设计——服务熔断和降级设计
![[station B up dr_can learning notes] Kalman filter 1](/img/18/ee21d31f6a118e4e4ad466b55361cc.gif)
[station B up dr_can learning notes] Kalman filter 1

跟着BUU学习Crypto(周更)
![[station B up dr_can learning notes] Kalman filter 3](/img/40/d3ec97be2f29b76a6c049c26ff4998.gif)
[station B up dr_can learning notes] Kalman filter 3
随机推荐
Advanced Mathematics (Seventh Edition) Tongji University exercises 1-10 personal solutions
017 C语言基础:位域和typedef
In a sense, the Internet has become an incubator and a parent
快速排序(非遞歸)和歸並排序
微服务系统设计——统一鉴权服务设计
Golang Hello installation environment exception [resolved]
ES6 0622 III
How to make ef core 6 support dateonly type
轨道姿态常用编程缩写
微服务系统设计——微服务监控与系统资源监控设计
021 C语言基础:递归,可变参数
低代码开发平台NocoBase的安装
Vue学习笔记(五)Vue2页面跳转问题 | vue-router路由概念、分类与使用 | 编程式路由导航 | 路由组件的缓存 | 5种路由导航守卫 | 嵌套路由 | Vue2项目的打包与部署
微服务系统设计——消息缓存服务设计
Why does C throw exceptions when accessing null fields?
渗透测试-文件上传/下载/包含
010 C language foundation: C function
008 C语言基础:C判断
Fastdds server records - Translation-
nignx配置单ip限流