In the previous study of text box input, the event response of button press and pop-up, now let's learn the events that are triggered when the content of the text box changes.
Definition and usage The change event occurs
when the value of an element changes (applies only to form fields).
The change() method triggers the change event, or specifies a function to run when the change event occurs.
Note: When used on select elements, the change event occurs when an option is selected. When used in a text field or text area, the change event occurs when the element loses focus.
You can use the following example to test:
Backgammon game development
http://edu.csdn.net/course/detail/5487
Definition and usage The change event occurs
when the value of an element changes (applies only to form fields).
The change() method triggers the change event, or specifies a function to run when the change event occurs.
Note: When used on select elements, the change event occurs when an option is selected. When used in a text field or text area, the change event occurs when the element loses focus.
You can use the following example to test:
<html> <head> <meta charset="utf-8"> <script type="text/JavaScript" src="jquery/jquery-3.3.1.js"></script> </head> <script> $(document).ready(function(){ $("input").change(function(){ alert("The text of the text box has changed."); }); }); </script> <body> Please enter: <input type="text"> </body> </html>
Result of running: