0

i'm trying to select all td elements that are within a time period of 0-3 minutes. The time format is a weird combination of words and numbers.

Right now I am able to select rows that are 0-1 minutes old like this:

$(".some-class td:contains('now')");

What I would like to be able to do is something like this:

$(".some-class td:contains('now' || '1 minute' || '2 minutes')");

But I realize that this does not work. I am aware that there are examples in other question on how to write a loop and executing a jQuery inside the loop, adding each result to a single collection. But I was wondering if there would be a jQuery one liner that would take in multiple values and finding all elements that contains one of those values without looping manually, or without selecting multiple times and concat'ing the results.

2 Answers 2

2

You're looking for a selector group:

$(".some-class td:contains('now'), .some-class td:contains('1 minute'), .some-class td:contains('2 minutes')");

A selector group is a series of selectors with commas in-between. It selects elements matching any of the selectors in the group.

Sign up to request clarification or add additional context in comments.

1 Comment

Sweet this is exactly what meant! Not knowing the right term just makes it very difficult google. Thanks! "selector group" it is
1

You can use

$(".some-class td").filter(":contains('now'), :contains('1 minute'), :contains('2 minutes')");

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.