javascript添加更多select2下拉列表

时间:2019-06-14 10:39:33

标签: javascript

enter image description here,当我单击“添加新按钮”时,select2下拉列表无法响应正确的CSS滚动不可见,边框也不可见

var counter = 1;

    $(".add_new").click(function () 
    {
        counter++;

        /*if(counter >= 3)
        {
            $('.add_new').prop('disabled',true);
        }*/   

        var newtr = $(document.createElement('tr')).attr("id", 'tr' + counter) .attr("class", 'tr_add'); 
        newtr.after().html('<td><select class="form-control" name="joint_br_code[]" id="joint_br_code'+counter+'" onchange="get_customer_ids(this.value, '+counter+')">'+
                            /*'<option value="">Select Branch</option>'+*/
                            '</select></td>'+
                            '<td><select class="selectDistrict select2 select2-hidden-accessible" name="joint_customer_id[]" id="joint_customer_id'+counter+'" onchange="get_Jointcustomer_name(this.value, '+counter+')">'+
                            '<option value="">Select Customer Id</option>'+
                            '</select></td>'+
                            '<td><input type="text" class="form-control" name="joint_customer_name[]" id="joint_customer_name'+counter+'"></td>'+
                            '<td id="'+counter+'" style="text-align:center;"><a href="#" class="btn btn-danger btn-xs remove-box">Remove</a></td>'+
                            '</tr>');
        newtr.appendTo("#join_account_body");

        $('#joint_customer_id'+counter).select2();

    });

var计数器= 1;         var session_branch_id = $('#session_branch_id')。val();

    $(".add_new").click(function () 
    {
        counter++;

        /*if(counter >= 3)
        {
            $('.add_new').prop('disabled',true);
        }*/   

        var newtr = $(document.createElement('tr')).attr("id", 'tr' + counter) .attr("class", 'tr_add'); 
        newtr.after().html('<td><select class="form-control" name="joint_br_code[]" id="joint_br_code'+counter+'" onchange="get_customer_ids(this.value, '+counter+')">'+
                            /*'<option value="">Select Branch</option>'+*/
                            '</select></td>'+
                            '<td><select class="selectDistrict select2 select2-hidden-accessible" name="joint_customer_id[]" id="joint_customer_id'+counter+'" onchange="get_Jointcustomer_name(this.value, '+counter+')">'+
                            '<option value="">Select Customer Id</option>'+
                            '</select></td>'+
                            '<td><input type="text" class="form-control" name="joint_customer_name[]" id="joint_customer_name'+counter+'"></td>'+
                            '<td id="'+counter+'" style="text-align:center;"><a href="#" class="btn btn-danger btn-xs remove-box">Remove</a></td>'+
                            '</tr>');
        newtr.appendTo("#join_account_body");

        $('#joint_customer_id'+counter).select2();

    });

0 个答案:

没有答案