Gilles (Webunity) wrote:
Let's say i have this construction:

<form>
<fieldset>
<legend></legend>
<input type="text" class="textField" ...>
</fieldset>
</form>

And i have this query
$('.textfield').each(function() { ... });

How do i find the parent form?
a) jQuery('form').contains(this);
b) jQuery(this).parents('form').. ?

What is the best and fastest way?

I'm sure the fastest way is to use the form property every form element has, most probably it is the safest as well:

$('input.textField').each(function() {
    var form = this.form;
});

No jQuery involved though...

By the way, the selector "input.textField" will perform better than just ".textField".


--Klaus

Reply via email to