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 -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -