Check if input is textbox, select, textarea or radio

jquery

Solution

$('input') // selects all types of inputs
$('input:checkbox') // selects checkboxes
$('select') // selects select element
$('input:radio') // selects radio inputs
$('input[type="text"]') // selects text inputs

you can use `event.target.type`, this alerts what type of `input`, `textrea` or `select` is the target of the event.

$('input, textarea, select').change(function(event){
   alert(event.target.type)
})

http://jsfiddle.net/Q4BNH/

Problem

I have a form with different html input fields... ``` 1) <input type="text"> 2) <textarea></textarea> 3) <input type="checkbox"> 4) <input type="radio"> 5) <select></select> ``` How would I be able to determine what type of input field it is using jQuery. For example: If I wanted to do a check to see if input = "select" then do stuff.

Original source