Home >>jQuery Tutorial >jQuery change() Events
The change() Events in jQuery is used to attaches a function to run when a change event occurs or triggers the change event.
Syntax:Trigger the change event for the selected elements: | $(selector).change() |
Attach a function to the change event: | $(selector).change(function) |
Parameter | Description |
---|---|
function | It is optional parameter and is used to Specifies the function to run when the change event occurs for the selected elements |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").change(function(){
alert("The text has been changed.");
});
});
</script>
</head>
<body>
<input type="text">
<p>Write something in the input field, and then press enter or</p>
</body>
</html>
Write something in the input field, and then press enter or