Exit JS Function out of jquery each loop?

  each, javascript, jquery

I’m using a jquery $.each function to do some things in a table. If some value in this table is empty, I want to stop the complete function.
"return false;" is only breaking the each loop, but not the complete function.
How can I do this?

function readFields(){
    $('#tbl_units').each(function(key, value){
        if($(value).val() === undefined){
           return false; //This one will only break the .each, but not the complete readFields-function. But I want to completely exit the readFields function
        }
        //Some other stuff todo
    }
}

Thank you for your help

Source: Ask Javascript Questions

LEAVE A COMMENT