jquery - Loading options in Dropdown (using delegate) -
hello everyone
in code, there 1 drop down list. want add options it. have used following code. adding fields via jquery. after that, can not select option drop down. think because of click event..
var myoptions = { 'india' : 'india', 'sri lanka' : 'sri lanka', 'uae' : 'uae', 'qatar' : 'qatar' }; var drop_down = jquery("[name='ab-custom-field-1252']"); jquery("body").on('click',drop_down,function() { var myselect = jquery("[name='ab-custom-field-1252']"); myselect.html(''); jquery.each(myoptions, function(val, text) { myselect.append( jquery('<option></option>').val(val).html(text) ); }); });
can me? highly appreciated.
Comments
Post a Comment