javascript - 下拉菜单在 jquery 数据表移动视图中不起作用
问题描述
转到小提琴 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>
解决方案
尝试使用.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'));
});
推荐阅读
- python - 如何在特定间隔下绘制符号函数
- terraform - Terraform Data Fusion 实例更改导致计划期间发生错误
- azure-devops - 可以在 DevOps 中创建看板来显示来自两个不同项目的工作项吗?
- css - 无法在css中加载背景图像
- java - 无法使用唯一键从 Firebase 检索用户位置数据
- jenkins - 詹金斯管道 - 这个功能来自哪里
- mysql - SQL:将列值链接到列名以满足某些条件
- apache-kafka - KafkaConsumer 未能“重新订阅”
- python - 在尚未开始计算的情况下持续存在内存延迟
- postgresql - Sqoop 从 Postgre 到 Hive 并转换为 ORC 格式