The jQuery on input change event works when using on("input")
method. You can use this method to get the value of input field when enter content on it.
Syntax
The syntax of the method is given below:-
Syntax to Return the Value Attribute
$(selector).on(‘input’, function(){
$(this).val();
});
$(this).val();
});
Description of the Parameters
The description of the parameters are given below.
Parameter Name | Description |
---|---|
selector | The selector is used to select the input elements to get value on enter content. Enter tag name, class name, or id of the elements to select. |
this | Select the current clicked element to get its value. |
Examples of jQuery on(“input”) Method to Get Value on Input Change
Get Value on Enter Content
To get value on input change event in jQuery, you can check the example given below.
Example 1
1 2 3 4 5 6 7 8 |
<script> $(document).ready(function(){ $('input').on('input', function(){ var myvalue = $(this).val(); alert(myvalue); }); }); </script> |
You may also like to read