2

hi i was wondering if there is a way to use multiple strings in the jquery selector :contains(). for example I would liek to do something like this:

 $("#"+idArray[i]).find("th:Contains(" + query && query2 + ")").closest($(".instTable, .break")).show();

similar to an if statement's sysntax. is this possible?

thanks

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
arrowill12
  • 1,784
  • 4
  • 29
  • 54

2 Answers2

1

Sure, as you want an and condition, that's just the same as filtering for both matches independently.

$(selector).find('th:contains(' + query1 +'):contains(' + query2 + ')') ...
Alnitak
  • 334,560
  • 70
  • 407
  • 495
  • @arrowill12 `or` is the same as a set union, so you could use two separate expressions and then use `.add` to merge them. – Alnitak Apr 12 '12 at 22:25
  • how would the syntax look for using `not:` with multiple contains ex. `:not(:Contains(" + query[x] + "))` – arrowill12 Apr 19 '12 at 22:57
1
$('th:contains('+ query +'), th:contains('+ query2 +')')....
adeneo
  • 312,895
  • 29
  • 395
  • 388