Select any value from the dropdown select and see the result.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Executing a Function on Change Event in jQuery</title> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script> $(document).ready(function(){ $("select").change(function(){ var selectedOption = $(this).find(":selected").val(); document.getElementById("demo").innerHTML = "You have selected - " + selectedOption; });/*from www .j a v a 2 s . c o m*/ }); </script> </head> <body> <p id="demo"></p> <form> <label>City:</label> <select> <option>London</option> <option>Paris</option> <option>New York</option> </select> </form> </body> </html>