通过多个可能的属性值进行选择的更简洁的方法? [英] A cleaner way to select by multiple possible attribute values?
本文介绍了通过多个可能的属性值进行选择的更简洁的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery 中是否有可能通过多个可能的属性值进行选择,而不必使用逗号分隔的选择器列表.
Is there a possibility in jQuery to select by multiple possible attribute values without having to use a comma separated list of selectors.
所以代替:
#list1 > option[value="1"], #list1 > option[value="2"], etc
类似于:
#list1 > option[value="1"|value="2"], etc
推荐答案
我不知道.我能想到的 最干净 方法是首先使用所有项目的公共元素进行选择,然后仅选择 .find()
或 .filter()
输出 OR 值.
Not that I know of. The cleanest way I can think of doing this is to first select using the common elements across all items, then just .find()
or .filter()
the OR values out.
类似的东西
$('#list1 > option[value]')
.filter('[value="1"],[value="2"]')
;
这篇关于通过多个可能的属性值进行选择的更简洁的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文