gpt4 book ai didi

Javascript 更改单选按钮标签的文本

转载 作者:行者123 更新时间:2023-12-03 08:21:01 25 4
gpt4 key购买 nike

我有以下自动生成的带有关联标签的单选按钮我想从标签文本中删除文本,并且只保留每个相应标签的以下文本得到正式认可的。拒绝。待办的。 在下面使用 javascript 自动生成的 HTML 中。(此html来自SharePoint的approve.aspx页面)

<table id="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus" class="ms-authoringcontrols">
<tbody><tr>
<td><input id="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus_0" type="radio" name="ctl00$PlaceHolderMain$approveDescription$ctl01$RadioBtnApprovalStatus" value="0" checked="checked">
<label for="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus_0">Approved. This item will become visible to all users.</label></td>
</tr><tr>
<td><input id="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus_1" type="radio" name="ctl00$PlaceHolderMain$approveDescription$ctl01$RadioBtnApprovalStatus" value="1">
<label for="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus_1">Rejected. This item will be returned to its creator and only be visible to its creator and all users who can see draft items.</label></td>
</tr><tr>
<td><input id="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus_2" type="radio" name="ctl00$PlaceHolderMain$approveDescription$ctl01$RadioBtnApprovalStatus" value="2">
<label for="ctl00_PlaceHolderMain_approveDescription_ctl01_RadioBtnApprovalStatus_2">Pending. This item will remain visible to its creator and all users who can see draft items.</label></td>
</tr>
</tbody></table>

最佳答案

您需要删除“.”后面的文本。像这样:

s = s.substring(0, s.indexOf('.'));

这是脚本:

var labels = document.getElementsByTagName('label');

for (var i in labels) {
var text = labels[i].innerHTML;
if (text) labels[i].innerHTML = text.substring(0, text.indexOf('.'));
}

这是一个jsfiddle: https://jsfiddle.net/mckinleymedia/c43hjohp/1/

关于Javascript 更改单选按钮标签的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33748889/

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