下拉列表在jquery datatable移动视图中无法正常工作

问题描述 投票:2回答:1

转到小提琴https://jsfiddle.net/rizwanali98601/ngofhc24/12/在下表中,jquery数据表中有下拉列表。

点击按钮,我在下拉列表中添加选项。但是在移动视图选项中没有添加到下拉列表中。

 <p>Click on Add option  button to add options in dropdown</p>
<button type="button" id="btn1">
Add option 

</button>
<br/>

<table class="table table-striped table-hover" id="myTable">
<thead>
<tr>
  <th>Indent No.</th>
  <th>Warehouse</th>
  <th>Item</th>
  <th>Make/Catno</th>
  <th>UOM</th>
  <th>Qty</th>
  <th>Qty P</th>
  <th>Sh Cl</th>
  <th>Date</th>
  <th>SortDate</th>
  <th>Rqt Dt</th>
  <th>Dropdown</th>          
  </tr>
</thead>
<tbody>
  <tr>
    <td>INDMSF/16-17/00003</td>

    <td>Furnace</td>
    <td>Bearing 22317 EW33J</td>
    <td></td>    
    <td>no</td>
    <td>2.0</td>  
    <td>2.0</td>
    <td></td>
    <td>31/08/16</td>
    <td>08/31/16</td>    
    <td>31/08/16</td>
     <td><select id="ddlTest" style="width: 300px"></select></td>
  </tr>
 </tbody>
</table>
javascript jquery datatables
1个回答
0
投票

尝试使用.on()

所以改变......

$("#btn1").click(function(){
    var ddl = $('#ddlTest');
    ddl.append($("<option></option>").val('0').html('Selectvalue'));
}); 

对此......

$("#btn1").on('click', function() {
    var ddl = $('#ddlTest');
    ddl.append($("<option></option>").val('0').html('Selectvalue'));
});
© www.soinside.com 2019 - 2024. All rights reserved.