Reputation: 101
I want to select an element based on their innertext in JQuery. Below is my Html
<html>
<body>
<a href="fddf">4</a>
<a href="fddf">4</a>
<a href="fddf">4</a>
</body>
</html>
I want to select all the <a>
tags which has text of "4". Any idea how do I do it?
Upvotes: 10
Views: 4314
Reputation: 71
I think the correct way is $("a[outerText='4']")
. Contains returns 4,44,444
etc. .
Upvotes: -1
Reputation: 887195
You're looking for the :contains
selector, like this:
$('a:contains("4")')
Upvotes: 16