Change() Method In JQuery

jQuery Event change() Method

It is only work on the text fields, text areas and selected elements. This event occur when the value of an element is changed.

The change() specifies a function to run when a change event occurs.

Note: In the drop down menu change event occurs when an option is selected for text fields or text areas, and also change event occurs when the field loses focus.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $(".field").change(function () {

            $(this).css("background-color", "yellow");

        });

    });

</script>

</head>

<body>

<p>When a field has been changed, it will change background color.</p>

Enter name: <input class="field" type="text" />

<p>bike:

<select class="field" name="bike">

<option value="honda">honda</option>

<option value="bajaj">bajaj</option>

<option value="hero">hero</option>

<option value="rajdoot">rajdoot</option>

</select>

</p>

</body>

</html>