Hi Choan!

> > I have this in my validation plugin to check the number of selected
> checkboxes/radios:
> >
> > return $(element).parents('form, body').find('[EMAIL PROTECTED]' + 
> > element.name +
> ']:checked').length;
> 
> I've used something similar which, as I understand, should be a little
> more efficient:
> 
> return $(element.form).find('[EMAIL PROTECTED]' + element.name +
> ']:checked').length;

Indeed, good to know. I'd write it then as this for cases where there is no 
surrounding form:

return $(element.form || document).find('[EMAIL PROTECTED]' + element.name + 
']:checked').length;

At least in FF the form property is null when there is no surrounding form. I 
wonder if this is true for other browsers.

--
Jörn Zaefferer

http://bassistance.de
-- 
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to