2016-11-11 9 views
0

これでエラーが発生します。私はここで何が起こるか分からない。

enter code here 
$(".addCategory").on('click',function(){ 
     var value= $(".getvalue").val(); 
     var x = $("input[name="+value+'[]'"]") 
     $(x).each(function(key,val){ 
     if($(val).val().length<=0) 
     { 
      alert ("Please fill all the fileds"); 

     } 

     }); 
    }); 

答えて

3

あなたが引用符

var x = $("input[name='" + value + "[]']") 
0

に問題があるが、それは

var x = $("input[name='"+value+"[]']") 
2

問題は、あなたの引用符とあった包む必要があります方法を参照してください: 次のコードで

$(".addCategory").on('click',function(){ 
      var value= $(".getvalue").val(); 
      var x = $("input[name='"+value+"[]']") // add proper quotes 
      $(x).each(function(key,val){ 
      if($(val).val().length<=0) 
      { 
       alert ("Please fill all the fileds"); 

      } 

      }); 
     }); 
を置き換えます
関連する問題