Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有以下简写版本:
$('input[hasThisAttr], input[hasThatAttr]')
我意识到这很短,但是如果您必须检查一堆共同的属性,然后检查不同的属性,它可能会变得非常冗长。
想多了,看起来过滤器可能是一个不错的选择。前任:
$("input").filter("[hasThisAttr],[hasThatAttr]")
这将抓取所有输入,然后根据您指定的 attr 列表进行过滤。