I am trying to find a <td>
where the value is 5. It is a calender so there will only be one 5 value.
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.
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).
find("tr td:eq(1)"). val();
How can I get input text value from inside TD? var data1 = $(this). find(“td:eq(0) input[type='text']”). val();
You can use filter method:
$('td').filter(function(){
return $(this).text() === '5'
})
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With