title: jQuery - How do I test what type of selector is passing the value?
body: <p>I am using the latest and greatest jQuery.  I am trying to make my code efficient and reusable throughout a specific site and want consolidate a block.</p>
  
  <p>I have a piece of code that listens for a save button being clicked. When the save button is clicked, it figures out which selector was click and gets its id and value.</p>
  
  <p>This code works perfectly for text boxes. I just want to be able to run select boxes, radio buttons, and check boxes through it too.  I need to handle the data differently depending on whether it's a checkbox, radio, or text field.</p>
  
  <p>If I know the id of a selector, how can I easily test which type of selector it is?</p>
  
  <p>In pseudocode:</p>
  
  <pre><code>if (SelectorType == 'radio') {
      // do radio stuff
  } else if  (SelectorType == 'text') {
      // do test field stuff
  } else if  (SelectorType == 'checkbox') {
      // do checkbox stuff
  }
  </code></pre>
  
  <p>ANSWER</p>
  
  <p>This is what I was trying to get at:  </p>
  
  <pre><code>    var ThisField = $(this).parent().parent().children("td:eq(1)").children(":input").attr("id");
  
      var FieldType = $("#"+ThisField).prop("type");
      if (FieldType == "select-one") {
          alert("You are trying to save select box info!");
      } else  if (FieldType == "text") {
          alert("You are trying to save text info!");
      } else  if (FieldType == "checkbox") {
          alert("You are trying to save checkbox info!");
      } else  if (FieldType == "radio") {
          alert("You are trying to save radio info!");
      }
  </code></pre>