[英]get values from dynamically generated drop down
I'm trying to get all selected
values from dropdown
that is being populated after accessing some value from first select box
( ajax
call). 我正在尝试从第一个select box
( ajax
调用)访问某些值后,从正在填充的dropdown
中获取所有selected
值。
here what I've tried so far, 这是我到目前为止尝试过的
$(document).on('change', '#modal', function(){
obj.push($('#modal').val());
});
console.log(obj);
#modal
is the id
of newly populated select
box. #modal
是新填充的select
框的id
。
#make
is the id
of main select
. #make
是main select
的id
。
I've tried these two as well 我也尝试过这两个
$('#make').on('change', '#modal', function(){
and 和
$('#modal').on('change', '#modal', function(){
but no luck by far 但到目前为止没有运气
PS. PS。 I'm using select2
我正在使用select2
You can retrieve the selected
values from your #modal select
in your ajax success callback
after populating the select. #modal select
,您可以从ajax success callback
#modal select
中检索selected
值。
For example http://jsfiddle.net/99hacq59/ 例如http://jsfiddle.net/99hacq59/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.