Jquery event when user makes selection in dropdown

前端 未结 4 567
北荒
北荒 2020-12-29 12:17

I have a drop down list. In Jquery what is the event I would use when the user makes a selection.

The id of the dropdown is drp1

I tried the following but di

4条回答
  •  误落风尘
    2020-12-29 13:04

    Use jQuery change event handler.

    $("#ddrp1").change(function(){
        //selection changed
        alert(this.value);//this will give the selected option's value
        alert($(this).find(':selected').text());//this will give the selected option's text
    });
    

    Alternative way to bind change event handler is.

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

提交回复
热议问题