Check if all elements satisfy a condition

前端 未结 8 844
栀梦
栀梦 2020-12-10 11:05

I need a jQuery filter/map/each type function to check if ALL elements satisfy a condition:

function areAllValid(inputs){
     return $.someFunction(inputs,          


        
8条回答
  •  眼角桃花
    2020-12-10 11:30

    The answer is YES, it has a method grep that can meet your requirement. For example:

    inputs= jQuery.grep(inputs, function(input){
    return input.length>0;
    });
    if(inputs.length>0) return true;
    return false;
    

    I don't test it, maybe it has tiny issue but should be almost like this.

提交回复
热议问题