title: Serialize form data of a certain form out ot many, if a certain field has value jQuery
body: <p>I have a page with a couple of forms (number is different, as they are loaded dynamically). I am able to cycle through every form on the page and serialize its data to send to my server. I was wondering if it's possible to only serialize/add data to the array only if a checkbox in any given form is ticked (and that gives it a value I need to use)?
  Here is my code:</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>$('body').on('click', '.saveStates', function () {
      $('.states_list').each(function (key, value) {
              forms.push($(this).serialize());
      });
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>   &lt;form class="states_list"&gt;
      &lt;input type="checkbox" class="selected_state" name="active_state" value="&lt;?php echo $state['id']; ?&gt;"
      &lt;input type="text" class="col-md-10" name="pdf_price" id="pdf_price" value="&lt;?php echo $state['pdf_price']; ?&gt;"&gt;
      &lt;/form&gt;
  &lt;button type="button" class="saveStates btn btn-success"&gt;Save&lt;/button&gt;
  </code></pre>
  
  <p>I need to check if the checkbox with class <code>selected-state</code> has a value (is ticked), and then add that form to the <code>forms</code> array. I was thinking of doing something like this:</p>
  
  <pre><code>$('.states_list').each(function (key, value) {
      if($('.selected_state').val()){
          forms.push($(this).serialize());
  }
  });
  </code></pre>
  
  <p>But that does not work.
  Any help is welcome.</p>