I have a table with mutiple div tags inside a td tag and I want to get the text value of the div using jquery
Code
A
R
A
Denied
>I want to do
JavaScript
if(the div text == "A")
{
show all the tr with the div tags with "A" inside the td
}Any help will be appreciated

Tuhin PaulRank #7 · 71.9K reputationPosted May 1, 2023, 2:50 PM EDT
See the code, this code will show all tr elements that contain a div element with text "A" inside a td element of the table:
// iterate through each td element in the table $("table td").each(function() { // get the text content of the div inside the td element var divText = $(this).find("div").text().trim(); // check if the div text matches "A" if (divText === "A") { // show the parent tr element of the td containing the div with text "A" $(this).closest("tr").show(); } });Ali BenchaabanRank #925 · 2.2K reputationPosted Mar 22, 2023, 7:41 PM EDT
To get the value of div content in jQuery, use the text() method
$(document).ready(function() { if($('.success').text()== "A") { do something; } });Deepak RawatRank #646 · 3.7K reputationPosted Apr 30, 2023, 9:17 AM EDT
the jQuery code loops through each
tdelement and finds thedivelement with classmy-divinside it using thefind()method. It then gets the text value of eachdivelement using thetext()method and logs it to the console. You can modify the code to suit your specific use case.// jQuery code to get text value of div elements inside td element $('td').each(function() { var divText = $(this).find('.my-div').text(); console.log(divText); });Tuhin PaulRank #7 · 71.9K reputationPosted May 1, 2023, 2:48 PM EDT
You can use jQuery to iterate through all the
divelements within thetdelements of the table, and check the text content of eachdivelement.