necrofish666 necrofish666 - 3 months ago 5x
HTML Question

Can't get javascript to assign id to hidden field

I have a script file on called scripts.js, which contains only the following code:

$("body").on("click", ".btnDelete", function() {
var trid = $(this).closest('tr').attr('id');

Nothing else. Literally nothing else at all in that file. I've checked and when I load the page the script file is being loaded. I set a breakpoint at the 'var trid' bit, and when I click on the button with the btnDelete class name, the breakpoint never gets hit, the script doesn't fire. Anyone any idea why?


Have you tried using $(document).on("click"... instead of $("body").on("click"...?