On 04/01/07, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Andreas Wahlin schrieb:
> > Is there a way to break the $.each loops?
> > I'd like it to be
> > $.each(object, function() {
> > break;
> > });
> >
> > but it doesen't seem so.
> >
> > Andreas
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
>
> Andreas, if I remember correctly, the following should work:
>
> $.each(object, function() {
>
> return false;
> });
>
>
> -- Klaus
Done a test (requires Firebug - or Firebug lite (which I presume would
also work)).
var foo = ["one", 2, "three", new Date()];
$.each(foo,
function()
{
if(this === 2) return false;
console.log(typeof this);
}
)
This logs:
["o", "n", "e"]
2
["t", "h", "r", "e", "e"]
Thu Jan 04 2007 13:09:12 GMT+0000 (GMT Standard Time)
To the console, rather than just:
"one"
typeof(this) within $.each always returns 'object', so identity
comparison doesn't work (you have to use == instead of ===)
Also, why does a string get returned as an array instead of a string?
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/