I need to find the input type for radio buttons, text, and selects. Its easy to find the input type of anything with <input type="x">
since $(this).attr("type")
would return x
My issue is that I need to support <select>
elements, which dont have the type attribute. The end goal is to do return either radio, text, or select.
I thought of doing something like this, but I was curious if there's a better way:
if ($(this).tagName == "input") {
var result = $(this).attr("type"); //returns radio or text (the attr type)
} else {
var result = $(this).tagName; //returns select (the element type)
}
Thanks all!