javascript - Breaking out of a PrototypeJS .each() loop -


In this highly customized example, I have an array with 3 elements, which I'm looping when using the method I am

var vals = $ w ('foo barfish'); Vals.each (function (val) {alert (val); if (val == 'bar') {// This function exits (val) //, but still continues with .each () returns ;}});

I can easily return the function being called by .each () .

My question is, how can I eliminate .each () loop from within the strong> function? Calling .each ()?

  if (val == 'bar') {$ break; }  

This is documented on the same page linked to you. This is an exception specifically controlled by each function. When thrown, it prevents your function from calling on other elements.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -