title: How to append select option to a JQuery function
body: <p>I would like to add an input and select form elements to a Jquery function but i do not know how to go about it. At the moment i am able to only add one element. That is either an input or select form element. I want the function to contain fields for both input and select form elements.</p>
  
  <p>Jquery code</p>
  
  <pre><code>function collectFormData(fields) {
                  var data = {};
                  for (var i = 0; i &lt; fields.length; i++) {
                      var $item = $(fields[i]);
                      data[$item.attr('name')] = $item.val();
                  }
                  return data;
              }
  var $inputs = $form.find('input');
  var data = collectFormData($inputs)
  </code></pre>
  
  <p>Tried this but does not work.</p>
  
  <pre><code>var $selects = $form.find('select')
  var $inputs = $form.find('input').append($selects);
  var data = collectFormData($inputs)
  </code></pre>