Select table row and check checkbox using JQuery

jquery

Solution

$("table tr").each(function () {
    if ($(this).find("td:eq(1)").text().trim() == '2013-03-21') {
     $(this).find("input[type=checkbox]").attr("checked", true);
  }
});

DEMO

Problem

I have a table and I want to select the rows that satisfy my criteria and check their respective checkbox. Let's say I want to get the rows with date `2013-03-21`. How can I do this using JQuery? ``` <table> <tr> <td> Record1 </td> <td> 2013-03-21 </td> <td> <input type="checkbox"/> </td> </tr> <tr> <td> Record2 </td> <td> 2013-03-22 </td> <td> <input type="checkbox"/> </td> </tr> <tr> <td> Record3 </td> <td> 2013-03-21 </td> <td> <input type="checkbox"/> </td> </tr> </table> ```

Original source