0

I want to check the existence of this element on my html page

<a  ...>Intranet XXX Portal</a>

Via the console, I see that my element is there :

> $('a').text == "Intranet XXX Portal"
< true

But what I need is a selector where I can test the existence of the element via ".length > 0"

When I do the following, I always get an empty result.

> $('a[text="Intranet XXX Portal"]')
> $('a[innertext="Intranet XXX Portal"]')
> $('a[content="Intranet XXX Portal"]')
< []

What selector will return me a $('a???).length > 0 ?

REM: For this particular page, $ refers to the browser jQuery.

Joseph Marie
  • 193
  • 1
  • 5

1 Answers1

0

You can check the existence of that element by doing

if ($('a').html('Intranet XXX Portal').length > 0) {
    console.log(true)
}
else {
    console.log(false)
}

Hope it helps.

DevMoutarde
  • 599
  • 7
  • 21