过滤自定义选择器是否大于jQuery中的数字 [英] Filtering if a custom selector is greater than a number in jQuery
本文介绍了过滤自定义选择器是否大于jQuery中的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为您快速找到一个.我在jQuery.com中查看了选择器,但找不到通过大于数字的选择器进行过滤的方法?我想这样做:
quick one for you. I looked at the selectors in jQuery.com and could not find a way to filter by selector that is greater than a number? I want to do this:
$("[level>'4']").hide();
我的html看起来像这样:
My html looks like this:
<div id="1" level="4">Test</div>
如何使用该语法或类似语法隐藏大于4的所有div?4
how can I hide all divs greater than 4 using that or something like that syntax?4
推荐答案
尝试以下方法,
$("[level]").filter(function () {
return parseInt($(this).attr('level'), 10) > 4;
}).hide();
这篇关于过滤自定义选择器是否大于jQuery中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文