选择第一个"n". jQuery的项目 [英] Selecting the first "n" items with jQuery

查看:77
本文介绍了选择第一个"n". jQuery的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Jquery,我只需要从页面中选择前"n"个项目,例如前20个链接,而不用通常的方式选择所有这些

With Jquery, I need to select just the first "n" items from the page, for example the first 20 links instead of selecting all of them with the usual

$("a")

听起来很简单,但jQuery手册没有类似证据.

Sounds simple but the jQuery manual has no evidence of something like this.

推荐答案

您可能想阅读切片.您的代码将如下所示:

You probably want to read up on slice. Your code will look something like this:

$("a").slice(0,20)

这篇关于选择第一个"n". jQuery的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆