Javascript examples for jQuery Method and Property:change
Attach a function to the change event
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".field").change(function(){ $(this).css("background-color", "#D6D6FF"); });/*w w w. jav a2 s. c o m*/ }); </script> </head> <body> Enter your name: <input class="field" type="text"> Car: <select class="field" name="cars"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> <option value="d">d</option> </select> </body> </html>