gpt4 book ai didi

javascript - JS 或 Jquery : how to add an "option" to a checkbox

转载 作者:行者123 更新时间:2023-12-02 20:59:47 26 4
gpt4 key购买 nike

以 MS Sharepoint 表单创建的复选框具有以下 html 结构;

<div class="fd_field " fd_name="purchase_order" style="">
<div class="fd_title" style="width: 150px;">purchase_order</div>
<div class="ms-formbody fd_control" fd_type="MultiChoice">
<span dir="none">
<table cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td><span class="ms-RadioText" title="Carica dati">
<input id="ctl00_ctl40_g_2bbe8d3f_1b61_4103_9ca6_2e943eb28860_purchase_orderField_ctl00_ctl00" type="checkbox" name="ctl00$ctl40$g_2bbe8d3f_1b61_4103_9ca6_2e943eb28860$purchase_orderField$ctl00$ctl00">
<label for="ctl00_ctl40_g_2bbe8d3f_1b61_4103_9ca6_2e943eb28860_purchase_orderField_ctl00_ctl00">Carica dati</label></span>
</td>
</tr>
</tbody>
</table>
</span>
</div>
</div>

使用ajax,我得到了其他数据,我想将它们添加为该复选框中的选项。检索数据的循环不是问题,但是我如何将这些数据附加到复选框的新行中?过去我可以编辑下拉字段,但它不适用于复选框。

我正在考虑这样的解决方案:

var f = '<tr><td><input type="checkbox" name="xxx" id="ss"><label for="ss">Other</label></td></tr>';
$( ".ms-RadioText" ).parent().append(f);

谢谢

最佳答案

你是说这个吗?

PS:我不希望在跨度中出现一个表格!

var f = '<tr><td><span class="ms-RadioText" title="XXX"><input id="ss" type="checkbox" name="xx"><label for="ss">Other</label></span></td>';
$(".ms-RadioText").closest("tbody").append(f);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="fd_field " fd_name="purchase_order" style="">
<div class="fd_title" style="width: 150px;">purchase_order</div>
<div class="ms-formbody fd_control" fd_type="MultiChoice">
<span dir="none">
<table cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td><span class="ms-RadioText" title="Carica dati"><input id="xx" type="checkbox" name="xx"><label for="xx">Carica dati</label></span></td>
</tr>
</tbody>
</table>
</span>
</div>
</div>

关于javascript - JS 或 Jquery : how to add an "option" to a checkbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61384827/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com