I'm using the following code to attach an event to the submit button of a form :
$('form.manage-users-form').on('click','button.special',function() {
if ($(this).hasClass('selected')){
console.log('This user is already special');
} else {
$(this).parent().find('button').removeClass('selected');
$(this).addClass('selected');
var user_id = $(this).closest("form[id]").val();
console.log('This user is now special');
console.log(user_id);
}
return false;
});
And you can see that I'm also trying to get the id of the form, but when I check the console I get (an empty string)
. Why is that and how can I properly get the ID of the form ?