Jquery event when user makes selection in dropdown

Use the change() event:

$("#ddrp1").change(function() {
    // Pure JS
    var selectedVal = this.value;
    var selectedText = this.options[this.selectedIndex].text;

    // jQuery
    var selectedVal = $(this).find(':selected').val();
    var selectedText = $(this).find(':selected').text();
});

In jQuery 1.7, you can use .on()

$("#ddrp1").on("change", function() {
    // Pure JS
    var selectedVal = this.value;
    var selectedText = this.options[this.selectedIndex].text;

    // jQuery
    var selectedVal = $(this).find(':selected').val();
    var selectedText = $(this).find(':selected').text();
}​​​​);​

Here's a working jsFiddle using on()


What you want is onchange event which can be written as

 $("#ddrp1").change (function () { 
 });

Tags:

Jquery