Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery find table cell where value is X

I am trying to find a <td> where the value is 5. It is a calender so there will only be one 5 value.

like image 523
LeBlaireau Avatar asked Oct 05 '12 13:10

LeBlaireau


People also ask

How to get particular cell value in jQuery datatable?

As we need to access specific div/span content inside table TD, we will use jquery . find() method. Using the jQuery . find() method and pass class-name of a specific HTML element we able to get the table cell value of specific div / span content.

How to get value from table cell jQuery?

To get the value of the clicked cell, the jQuery solution is to attach a click event to all the table cells and assign the highlight CSS to the clicked cell and obtain its value. Then show this value on the screen by assigning it to the span element. Here is the complete jQuery code: $(document).

How to find TD of tr in jQuery?

find("tr td:eq(1)"). val();

How can I get TD value?

How can I get input text value from inside TD? var data1 = $(this). find(“td:eq(0) input[type='text']”). val();


2 Answers

You can use filter method:

$('td').filter(function(){
    return $(this).text() === '5'
})
like image 85
undefined Avatar answered Sep 19 '22 16:09

undefined


Use the :contains selector:

var td = $("td:contains('5')");

Edit: This will also select the td with 15 and 25, if you want exact 5, then use the .filter method as the other answer said.

like image 28
xdazz Avatar answered Sep 18 '22 16:09

xdazz