当前位置:网站首页>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 必需要有,用以规定元素的索引。可以是整数或负数。其中,使用负数将从被选元素的结尾开始计算索引。
边栏推荐
- Laptop does not have WiFi option solution
- Common programming abbreviations for orbit attitude
- Microservice system design -- service registration, discovery and configuration design
- 【Unity】UI交互组件之按钮Button&可选基类总结
- 清华大学开源软件镜像站网址
- 机械转码日记【17】模板,STL简介
- math_数集(数集符号)和集合论
- How pychart installs packages
- 2022-06-26: what does the following golang code output? A:true; B:false; C: Compilation error. package main import “fmt“ func main() { type
- DAST 黑盒漏洞扫描器 第六篇:运营篇(终)
猜你喜欢

跟着BUU学习Crypto(周更)

Qchart note 2: add rollover display

Is the truth XX coming? Why are test / development programmers unwilling to work overtime? This is a crazy state

Microservice system design -- service registration, discovery and configuration design

Système de collecte des journaux

Cultural tourism light show breaks the time and space constraints and shows the charm of night tour in the scenic spot

低代码开发平台NocoBase的安装

Office VR porn, coquettish operation! The father of Microsoft hololens resigns!

渗透测试-目录遍历漏洞
![[station B up dr_can learning notes] Kalman filter 1](/img/18/ee21d31f6a118e4e4ad466b55361cc.gif)
[station B up dr_can learning notes] Kalman filter 1
随机推荐
高等数学(第七版)同济大学 习题1-10 个人解答
Why does C throw exceptions when accessing null fields?
1.5 conda的使用
STM32关闭PWM输出时,让IO输出固定高或低电平的方法。
RTP 发送PS流工具(已经开源)
Kotlin compose custom compositionlocalprovider compositionlocal
流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)
Microservice system design -- microservice invocation design
Golang Hello installation environment exception [resolved]
019 basics of C language: C preprocessing
Installation of low code development platform nocobase
How to make ef core 6 support dateonly type
neo4j community与neo4j desktop冲突
011 C language basics: C scope rules
017 basics of C language: bit field and typedef
011 C语言基础:C作用域规则
How pychart installs packages
Is the truth XX coming? Why are test / development programmers unwilling to work overtime? This is a crazy state
The most detailed download tutorial of MySQL
深潜Kotlin协程(十五):测试 Kotlin 协程