How can I get the value of current td column value on KeyPress method given in javascript

I am trying to get the current column value in keypress event given in javascript. Here is the code

 $(document).ready(function () {
  $("td").keypress(function (e) {
            var tr = $(this).parents('tr');
            var rownumber = tr.index();
            var colname = $(this).attr("class");            
        });
        
        if(colname == 'HolidayHrs')
        {
          var holidayhrs = the column value of the current row
        }
 })
 
 
<table>
  <tr>
    <td class="HolidayHrs"><a href="#" data-pk="HolidayHrs">@Model.attendanceLogList[i].HolidayHrs</a><input  asp-for="@Model.attendanceLogList[i].HolidayHrs" type="hidden" class="bros"/></td></td>
  </tr>
</table>

4 thoughts on “How can I get the value of current td column value on KeyPress method given in javascript”

Leave a Comment