jeudi 26 mars 2015

Select a submit button of a form that received a change() event with jQuery

I need to build a jQuery script that would select a button with type=submit of a form that receives a change() event.


This is the code I've come up with:



var categoryEditForms = $('form.category-edit-block');
categoryEditForms.change(function(form) {
var submitButton = $(form).find('button[type=submit]');
});


After running this code categoryEditForms include 4 forms that are present on the page. submitButton is a JS object of length equal 0. I will only add that the submit button exists inside every form on a page.


How should I amend my code to grap the desired submit button?


Aucun commentaire:

Enregistrer un commentaire