Thursday, September 27, 2012

Break for Jquery each function


var myarray = new Array();
myarray[0] = "balaji";
myarray[1] = "prasad";
myarray[2] = "cbe";
myarray[3] = "coimbatore";
myarray[4] = "done";

arraycount = 0;

try {
    $.each(myarray, function () {
        alert(arraycount);
        if (myarray[arraycount] == "cbe") {
            alert(myarray[arraycount]);
            throw 'loop done';
        }

        arraycount = arraycount + 1;
    });
}
catch (e) { }

No comments:

Post a Comment