I have a form like this:
<form name="filter">
<input type='number'>
<input type="text">
<input type="range">
</form>
I want to get the type of input i use but i do not succeed in it
$(document).on('input', 'form[name="filter"]', function () {
alert(this.type); // alerts undefined
});
Based on the input i use, i expect an alert like: number, text or range, but i got "undefined" What i am doing wrong?
You need to add parameter & use like this to get input
type.
$(document).on('input', 'form[name=filter]', function(input) {
console.log(input.target.type)
});
<form name="filter">
<input type='number'>
<input type="text">
<input type="range">
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>