javascript - Check if all values are field -


<div class="answer_1">           <input id="1" class="1 inputs letter square border_black" maxlength="1" type="text" />           <input id="2" class="2 inputs letter square border_black" maxlength="1" type="text" />           <input id="3" class="3 inputs letter square border_black" maxlength="1" type="text" />           <input id="4" class="4 inputs letter square border_black" maxlength="1" type="text" />           <input id="5" class="5 inputs letter square border_black" maxlength="1" type="text" />           <input id="6" class="6 inputs letter square border_black" maxlength="1" type="text" />           <input id="7" class="7 inputs letter square border_black" maxlength="1" type="text" />           <button id="continue" class="btn btn-primary" value="continue">weiter</button> </div> 

and values of input field dinamicly js on click on image (every input field click on other image). how can check if values field (i tried keyup function, work when manualy field inputs, not js, , if clicke, css change (for example, when inputs value field, change background of div) thanks.

try this:

$(document).ready(function(){     $('.btn').click(function(){         var isempty = false;         $('input[type="text"]').each(function(){             var len = $.trim($(this).val()).length;             if( len === 0)                 isempty = true;         })          if (!isempty)             $('.answer_1').addclass('chn');         else             $('.answer_1').removeclass('chn');     }) }) 

$(document).ready(function(){      $('.btn').click(function(){          var isempty = false;          $('input[type="text"]').each(function(){              var len = $.trim($(this).val()).length;              if( len === 0)                  isempty = true;          })            if (!isempty)              $('.answer_1').addclass('chn');          else              $('.answer_1').removeclass('chn');      })  })
.chn {      background-color: green;      padding: 5px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>   <div class="answer_1">      <input id="1" class="1 inputs letter square border_black" maxlength="1" type="text" />      <input id="2" class="2 inputs letter square border_black" maxlength="1" type="text" />      <input id="3" class="3 inputs letter square border_black" maxlength="1" type="text" />      <input id="4" class="4 inputs letter square border_black" maxlength="1" type="text" />      <input id="5" class="5 inputs letter square border_black" maxlength="1" type="text" />      <input id="6" class="6 inputs letter square border_black" maxlength="1" type="text" />      <input id="7" class="7 inputs letter square border_black" maxlength="1" type="text" />      <button id="continue" class="btn btn-primary" value="continue">weiter</button>  </div>


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -