我正在将“ Select2”安装到下拉列表框中,该列表适用于除表格中的框以外的所有框

时间:2019-02-10 07:49:13

标签: javascript php html jquery-select2

Select2在我的所有字段中都起作用,除了表中列出的字段

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>  
<script>
         $(document).ready(function(){

          $(document).on('click', '.add', function(){
           var html = '';
           html += '<tr>';
           html += '<td><input type="text" name="item_name[]" class="form-control qty_onhand" /></td>';


           html += '<td><input type="text" name="qty_need[]" class="form-control qty_need" /></td>';
           html += '<td><select name="item_unit[]" class="js-example-basic-single form-control item_unit"><option value="">Select Unit</option><?php echo fill_unit_select_box($connect); ?></select></td>';
           html += '<td><button type="button" name="remove" class="btn btn-danger btn-sm remove"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
           $('#item_table').append(html);

          });
</script>
<script type="text/javascript">
      $('.js-example-basic-single').select2({
        placeholder: 'Select an option'
      });
</script>

class =“ js-example-basic-single-form-control item_unit”我添加了该类,但未应用select2

0 个答案:

没有答案