Javascript jquery选择器查询分组选择器和and

Javascript jquery选择器查询分组选择器和and,javascript,jquery,selection,custom-data-attribute,Javascript,Jquery,Selection,Custom Data Attribute,好吧,我陷入了一个非常尴尬的境地,我正试图为一组特定的规则创建一个选择器 每个元素都有一系列的数据属性,我试图匹配其中一些,查询如下 select all elements where data-1 contains (any of these) and with data-1 starts with this and with data-1 starts with that and with data-2 is this and with data-3 is this and with dat

好吧,我陷入了一个非常尴尬的境地,我正试图为一组特定的规则创建一个选择器

每个元素都有一系列的数据属性,我试图匹配其中一些,查询如下

select all elements where data-1 contains (any of these)
and with data-1 starts with this
and with data-1 starts with that
and with data-2 is this
and with data-3 is this
and with data-3 is this.
这就是人类所面临的问题,我的问题具体到查询的第一部分,我需要对一组OR进行有效分组,然后在最后抛出and

执行
[data-1*=“this”]、[data-1*=“that”][data-1^=“thing”]
会导致

select all elements where data-1 contains "this" or
select all elements where data-1 contains "that" and data-1 starts with "thing".
有人能帮我弄清楚吗?最好将其作为一个查询,而不是几个查询


我希望看到的是,
([data-1*=“this”],[data-1*=“that”])[data-1^=“thing”]
有效地将ors分组到查询的单个部分,但可惜这不起作用。

我根本不会反对这些属性。更新元素数据(例如,
$('.myclass')。数据('foo','bar')
不会更新属性。属性设置元素数据的初始值,但仅此而已

在您的情况下,我建议使用jQuerys过滤器函数

$('.some-class-common-to-all-candidates').filter(function(){
   var d = $(this).data('1');
   if( 'foo' == d ){
       return true;
   } else if( d > 10 ){
       return true;
   }
   // If we get this far then no match
   return false;
})
未经测试,我制定了条件,但你应该了解要点


您想表达什么?也许您可以链接一些
.filter()
调用?请尝试以下$('yourparentElement[data-1:contains(“-,-,-”)))。进一步了解您的密码。如果您可以共享您的代码,我可以更轻松地找出答案。我真的不明白您的情况是什么……这没有意义:
带数据-1从这个开始,带数据-1从那个开始
过滤器()
绝对是需要的。最坏的情况下,可以在选择器中使用数据属性本身而不使用值,例如
$(“[data-1]”)
嘿,谢谢你的帮助,尤其是文档的链接。我知道存在类似的东西,但我一辈子都记不起来了:)。