jQuery限制元素查询结果 [英] Jquery limit element query results

查看:52
本文介绍了jQuery限制元素查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
使用jQuery选择前"n"项

我有无数的元素列表!

是否有一个从列表开头查找x个元素并停止的功能!

Is there a function to find x elements from the head of the list and stop!

$('.elements').find('li').limit(10) //this does not work

我尝试了goog,但是我对它不够具体?!

I tried the goog but i could not be specific enough with the ? !

推荐答案

是的,您可以使用jQuery的自定义:lt 选择器.

Yes, you can use jQuery's custom :lt selector for that.

例如,这将在给定的目标列表中仅找到前三个 li :

For instance, this will find only the first three lis in the given target list:

var firstThree = $("#target li:lt(3)");

实时示例 |来源

这篇关于jQuery限制元素查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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