jQuery select元素包含一个链接,该链接包含数组的任何元素

jQuery select元素包含一个链接,该链接包含数组的任何元素,jquery,jquery-selectors,Jquery,Jquery Selectors,我正在尝试解决一个复杂的jQuery选择。我有一个数组,我需要选择包含链接a.bar的div.foo,该链接的href包含数组中的任何字符串 例如: <html> <div class=foo> some text <a class=bar href=example.com?q=widget&id=23456789>search</a> </div> </html> 我想突出显示这个div,因为查询字符串包

我正在尝试解决一个复杂的jQuery选择。我有一个数组,我需要选择包含链接
a.bar
div.foo
,该链接的
href
包含数组中的任何字符串

例如:

<html>
<div class=foo>
  some text
  <a class=bar href=example.com?q=widget&id=23456789>search</a>
</div>
</html>
我想突出显示这个div,因为查询字符串包含
23456789
,它是
widgets[]
中的元素之一

谢谢

选择包含“23456789”的所有
a
href属性与bar类一起使用 它们是所有div的直系后代 带着一个班级的foo

对于(小部件中的num)…:)。dosomething()适用于a.bar。我需要添加.parent()以应用于div.foo,但这正是我想要的。谢谢
widgets[0]='12345678';
widgets[1]='23456789';
widgets[2]='34567890';
$('div.foo > a.bar[href*=23456789');
for (num in widgets)
{
    $('div.foo > a.bar[href*=' + num + ']').doSomething();
}