Jquery event when user makes selection in dropdown

前端 未结 4 573
北荒
北荒 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:20

    You need to use change().

    jQuery change event occurs when the value of an element is changed.

    This event is limited to input elements, textarea boxes and select elements.

    $("#ddrp1").change (function () { 
    
         var getText = $(this).find(':selected').text();
         alert (getText); // show the text value of the selected element ...
    
     });
    

提交回复
热议问题