jquery - 如何放置选择输入 Html 表
问题描述
我在表格中放置一个选择下拉列表,但是当您单击下拉列表时,无法选择任何项目。
<table id="tbl_matches" style="width: 100%">
<thead>
<tr>
<th>Product</th>
<th>NHIS</th>
</tr>
</thead>
<tbody>
<tr>
<td>Paracetamol</td>
<td></td>
</tr>
<tr>
<td>Amoxy</td>
<td></td>
</tr>
<tr>
<td>Nico</td>
<td></td>
</tr>
<tr>
<td>Cefa</td>
<td></td>
</tr>
<tr>
<td>Amo</td>
<td></td>
</tr>
</tbody>
</table>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
let sel =
'<select id="product_select">' +
'<option>Para</option>' +
'<option>Amozy</option>' +
'<option>Chloro</option>' +
'<option>Niph</option>' +
'</select>'
$('#tbl_matches tbody').on( 'click', 'tr', function () {
$('#product_select').parents('td').html($('#product_select option:selected').text());
curr = $(this).find('td');
curr.eq(1).html(sel);
} );
</script>
当我单击下拉时,无法选择选择中的选项。单击表格行时,它会自动关闭下拉列表。
我有它的工作代码here
解决方案
推荐阅读
- java - java - 如何在java类中获取层列表项ID?
- python - 为什么这个 tensorflow.keras 代码会占用大量内存?
- javascript - 为什么即使数据库本身为真,MySQL 也会向客户端发送一个假布尔值?
- vb.net - DataGridView 数据源集列
- conda - conda build - 添加大量测试数据的推荐方法
- python - Python 一班带功能
- ruby-on-rails - 如果在 api 中创建失败,页面应该在哪里重定向
- asp.net-web-api - Automapper 映射两个不同结构的列表类以及成员显式映射
- redis - 是否需要在 Redis 集群之前放置负载均衡器
- node.js - MongoDB-在多个集合上运行相同查询、限制结果并在最后对它们进行排序的有效方法是什么