jQuery each method does not return value

后端 未结 1 429
梦谈多话
梦谈多话 2020-12-21 04:21
$(document).ready(function() {

    $(\'#commentForm\').submit(function(){

        return $(\'input[type=text], textarea\').each(function(index){

            if($(         


        
相关标签:
1条回答
  • 2020-12-21 05:07

    Yes, that's exactly how each works. Since it's actually a loop that calls your anonymous function in each iteration, exiting those functions, will not exit the calling function as well. Returning true and false here, is actually corresponding to the continue and break of the for loop, repsectively.

    You're gonna need to set a boolean flag, then return false (break), and then return the value of your boolean flag after the each

    0 讨论(0)
提交回复
热议问题