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?
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?
-
You can add HTML or source code to your question by indenting it with four spaces. (or by clicking the Format Code (
1010
) button in the toolbar) – SLaks Commented Jul 2, 2010 at 15:57 - possible duplicate of stackoverflow./questions/1430290/jquery-select-based-on-text – goodeye Commented Apr 19, 2012 at 5:58
2 Answers
Reset to default 16You're looking for the :contains
selector, like this:
$('a:contains("4")')
I think the correct way is $("a[outerText='4']")
. Contains returns 4,44,444
etc. .