title: How to loop through all elements of a form jQuery
body: <p>I was just wondering what the best way of looping through all the child elements of a form would be?
  My form contains both input and select elements.</p>
  
  <p>At the moment I have:</p>
  
  <pre><code>success: function(data) {
                  $.each(data.details, function(datakey, datavalue) {
                      $('#new_user_form &gt; input').each(function(key, value) {
                          if($(this).attr('id') == datakey) {
                              $(this).val(datavalue);
                          }
                      });
                  });
              }
  </code></pre>
  
  <p>This only loops through the input elements of the form though and I want to include the select elements too:</p>
  
  <p>I have tried:</p>
  
  <pre><code>$('#new_user_form &gt; input, #new_user_form &gt; select').each(function(key, value) {
  </code></pre>
  
  <p>but this doesn't work. Does anyone know why this would be happening?
  Thanks!</p>