Javascript 更改dynamic created select的onchange事件以填充另一个dynamic created select

Javascript 更改dynamic created select的onchange事件以填充另一个dynamic created select,javascript,jquery,onchange,Javascript,Jquery,Onchange,我有两个选择框,id分别为select1和otherselect1。我在select1上触发一个onchange事件,将数据附加到otherselect1 现在,我通过将id增加到+1来动态添加多个选择框组合。例如:选择2和其他选择2,选择3和其他选择3 问题是如何写入onchange事件,以便如果我更改select2,它只会影响otherselect2的数据,与select3和otherselect3类似 代码: $('.select_type')。在('change',function()上

我有两个选择框,id分别为select1otherselect1。我在select1上触发一个onchange事件,将数据附加到otherselect1

现在,我通过将id增加到+1来动态添加多个选择框组合。例如:选择2和其他选择2选择3和其他选择3

问题是如何写入onchange事件,以便如果我更改select2,它只会影响otherselect2的数据,与select3otherselect3类似

代码:

$('.select_type')。在('change',function()上{
var channel_type=$(this.val();
返回$.ajax({
url:_SITE.baseUrl,
数据:“信道类型=”+信道类型
成功:功能(数据)
{
如果(数据){
data=JSON.parse(数据);
var total=data.length;
$(this).next('.select_user').html('');
$(this).next('.select_user').append($('',{value:'',text:'Choose One'}));
对于(变量i=0;i
分别为所有
选择
其他选择
保留类似的类名,并使用
下一步()
追加从
中选择的数据。选择
下拉列表至
。其他选择
。检查下面的代码段以供参考

$('.select')。在('change',function()上{
$(this).next('.other select').append($(''){
文本:$(this.val())
}));
});

选择1
选择2
选择3
选择1
选择2
选择3
选择1
选择2
选择3
我自己解决了


onclick=“javascript_函数(this.id)”添加到所有select1中,并在javascript_函数中使用此id调用相应的otherselect1

,但在我的情况下,它不起作用。这是我的js代码。不允许我粘贴代码。说得太长了。在ques.$(this).next('.other select').val()中编辑它;提供未定义的。在fiddler中共享您的代码,以便查看。Thanx为Rajesh提供帮助
    $('.select_type').on('change', function() {
        var channel_type = $(this).val();

        return  $.ajax({
            url: __SITE.baseUrl ,
            data: "channel_type=" + channel_type
            success: function (data)
            {
                if (data) {
                    data = JSON.parse(data);
                    var total = data.length;
                    $(this).next('.select_user').html('');
                    $(this).next('.select_user').append($('<option/>', {value: '', text : 'Choose One'}));
                    for(var i=0; i < total; i++)
                    {
                        $(this).next('.select_user').append($('<option/>', {value: data[i]['id'], text : data[i]['name']}));
                    }
                }
            }
        });
    });