I have a form with some inputs and selects. I want to get the type of element on its click with jQuery. I know I can use attr("input")
to get if the element is radio, checkbox or text but what about selects
and textarea
?
Is there a overall function like .type()
to get it?
Getting the element type (input, select, div, span etc):
var elementType = $(this).prop('tagName');
Checking for specific element type:
var is_element_input = $(this).is("input"); //true or false
Getting the input type (input type="button"
etc)
var inputType = $(this).attr('type');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With