viery365
viery365

Reputation: 965

Using jQuery object of elements and :contains

I want to find if a link containing the word 'gathered'.

I am aware of the logic to get it but I am struggling to have a jQuery sintax for the selector:

if (index === 3) {

    var $link = $('#rest').find('.trigger');

    var $currentLinkPage = $link.eq(index - 1);

    $($currentLinkPage + ":contains('gathered')").......

}

The console returns: 'Syntax error, unrecognized expression: [object Object]:contains('gathered')'

Is there a way of using :contains in this case?

Upvotes: 0

Views: 26

Answers (1)

vol7ron
vol7ron

Reputation: 42099

$currentLinkPage.filter(':contains("gathered")')
  • Your $currentLinkPage is a jQuery object of .trigger elements
  • You only need to filter for the ones that contain the text you seek

Note: eq may not be what you need, update your question for what you're trying to get at

Upvotes: 1

Related Questions