javascript - Jquery if any element in a class meets the condition -


i want check if element in class meets conditions. example.

$(document).on('click','.modalinner_form_nav', function(){   var input = $(this).parents('.modalinner_form').find('.validate_g');    //$(input).each(function(index, element) {     if ($(input).val() == ''){         $(input).css('border', '#bb0000 1px solid');         return false;     }      else {       /////////go next///////////       if ($(this).parents('.modalinner_form').is(':last-child')){        }        else {         $(this).parents('.modalinner_form').slideup();         $(this).parents('.modalinner_form').next('.modalinner_form').slidedown();       }                          ////////////     } }); 

this returns false if input fields empty, if 1 in class not empty, returns true.

the problem have inner function so

$(document).on('click', '.modalinner_form_nav', function () {     var $form = $(this).parents('.modalinner_form');     var $input = $form.find('.validate_g');      var valid = true;     $input.each(function (index, element) {         var $this = $(this)         if ($this.val() == '') {             valid = false;             $this.css('border', '#bb0000 1px solid');         }     });      if (valid) {         if ($form.is(':last-child')) {             //do else         } else {             $form.slideup();             $form.next('.modalinner_form').slidedown();         }      } }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -