1

I have a table and in each column of each row I have a different number as a value

<table>
    <tr>
        <td>13</td>
        <td>15</td>
        <td>1</td>
    </tr>
</table>

I want to use Jquery to find the td with the value 1, I've tried with:

$('td[text="1"]')
$('td[html="1"]')
$('td[value="1"]')

But none of them is working, and if I use contains then I'll get the three of them which is not what I want.

Any ideas? Thank you.

1 Answer 1

2

Try to use .filter() with its helper function signature,

var elems = $('td').filter(function(){
 return this.textContent.trim() === "1"
});

DEMO

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

1 Comment

@Aldipa Glad to help! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.