我知道要过滤具有名为 attrName 且具有值 attrValue 的属性的元素,我会这样做:
filter("[attrName='attrValue']")
但查看文档 http://api.jquery.com/category/selectors/我看不到选择所有元素的选项 s.t.属性名>属性值
这行吗
filter("[attrName>'attrValue']")
最佳答案
您可以使用 .filter()
的函数重载来做到这一点,像这样:
.filter(function() {
return $(this).attr("attrName") > "someValue";
})
关于jQuery:选择属性大于值的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2613648/