gt 的条件 if/then:在 jQuery 中
你怎么说:
if there are more than 2 .quick_fact then
我的尝试:
if $(".quick_fact:gt(2)") { }
这显然总是正确的。
How do you say :
if there are more than 2 .quick_fact then
My attempt:
if $(".quick_fact:gt(2)") { }
Which evidently is always true.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 对象有一个
length
属性,表示匹配元素的数量。因此,只需进行典型的“大于”比较即可。A jQuery object has a
length
property representing the number of matched elements. So simply do a typical "greater than" comparison.或者:
Or: