Msdropdown - created via a function - attaches an onchange event

I am using msdropdown and I am creating a dropdown menu with the following function:

$("#select_holder_"+$_returnvalue.id+"").msDropDown({byJson:{data:jsonData, name:'change_member_status_'+$_returnvalue.id, width:'90'}}).data("dd");

      

Now I have a document ready:

$('select').on('change', function() {
alert( this.value ); 
});

      

But this doesn't fire when the dropdown created by the function changes (it fires on dropdowns created before the document already) and this behavior makes sense (since this is actually injected after documentready), but is there any way to hook up the onchange event for the dropdowns created with the function?

+3


source to share


1 answer


You can delegate the event:



$(document).on('change', 'select', function() {
    alert(this.value); 
});

      

+3


source







All Articles