Вопрос

I get "uncaught syntax error unexpected identifier"

I can't seem to find the syntax error. Im using the same code from an Lynda.com tutorial and it worked for him. Alas I hand typed the text, but it looks the exact same.

$(".member-form").submit(function() {
              var abort = false;
              $("div.error")remove();
              $(':input[required]')each(function() {
                  if ($(this).val()=== '') {
                      $(this).after('div class="error">This is a required field</div>');
                      abort = true;
                  }

              });  //go through each required value
              if (abort) { return false;} else {return true;}
          }); //on submit

any help appreciated as I just dont see anything wrong above

Это было полезно?

Решение

missing period before remove()

$("div.error").remove(); 
//            ^ add period

and each()

$(':input[required]').each(
//                   ^ add period

Другие советы

as soon as I posted I reviewed the code I hand copied, to recheck, and I see that there is no dot. before remove. And then did a face palm. Solved.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top