[jQuery] How to use context and reference it inside a jquery object
I have a question, is there a way to reference the context in a way
such as $(this)?
for example, let say I have this (using general selectors)
$('.forms').each(function(i) {
// I want to iterate over all forms
// here $(this) is each form
$(':input', $(this)).change(function(){
// Here I want to do something with the input element as well as
with the form element, but $(this) would be the input element, can I
do something to reference to the form element?
});
});
I am trying this but of course it doesn't work as eachForm ends up
being just the latest form
$('.forms').each(function(i) {
// I want to iterate over all forms
eachForm = $(this);
$(':input', $(this)).change(function(){
doSomething($(this),eachForm);
});
});
Thanks for any light in this,