necrofish666 necrofish666 - 1 year ago 99
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download