I want to get the name given for data-pk attribute for the current row in KeyPress method . Here is my code The Data-pk name 'Holidayhrs' must be printed in javascript .
<table> <tr> <td><a href="#" data-pk="HolidayHrs">@Model.attendanceLogList[i].HolidayHrs</a><input asp-for="@Model.attendanceLogList[i].HolidayHrs" type="hidden" class="bros" /></td> </tr> </table>
<script>
$("td").keypress(function (e) {
var tr = $(this).parents('tr');
var datapk = $(this).parents('tr').attr('data-pk');
var rownumber = tr.index();
console.log(rownumber);
console.log(datapk); // It is not working . The text 'HolidayHrs' must be printed
});
</script>
Member
414 Points
1339 Posts
How can I find and print data-pk attribute name from onkey press method in javascript
Feb 15, 2021 04:11 PM|polachan|LINK
I want to get the name given for data-pk attribute for the current row in KeyPress method . Here is my code The Data-pk name 'Holidayhrs' must be printed in javascript .