If you want to do something to every form on the page, you don't need
a class named form, just select the element. The "this" element in the
each is the DOM element, so you can create a jQuery object from that.
If you wanted you could use that element in a closure, or remember the
an input DOM element has a property named form that is the containing
form element.

So you could do this:

$("form").each(function(){
  $(":input", this).change(function(){
    // "this" is the DOM input element
    // $(this) is the jQuery of the element
    // "this.form" is the DOM form element
    // $(this.form) is the jQuery of the form
  );
);

or this:

$("form").each(function(){
  var $form = $(this);
  $form.find(":input").change(function(){
    // "this" is the DOM input element
    // $(this) is the jQuery of the element
    // use $form as the jQuery form element
  );
);

Or several variations in between.

Reply via email to