我有一个单选按钮列表,它由USPS的XML提要动态生成,如下所示:
<div id="pnlCartAllowsShippingMethodSelection">
<span id="ShipSelectionMsg"><p><b>Please select the desired shipping method below:</b></p></span>
<input type="radio" name="ShippingMethodID" id="ShippingMethodID3" value="41|Express Mail International|55.60|0.00"> Express Mail International $55.60 (USD)<span id="shippingdescription"> - Delivery in 3-5 Business Days*</span><br>
<input type="radio" name="ShippingMethodID" id="ShippingMethodID3" value="9|Priority Mail International|42.58|0.00"> Priority Mail International $42.58 (USD)<span id="shippingdescription"> - Delivery in 6-10 Business Days*</span><br>
<input type="radio" name="ShippingMethodID" id="ShippingMethodID3" value="67|First-Class Package International Service<sup>TM</sup>**|19.53|0.00"> First-Class Package International Service<sup>™</sup>** $19.53 (USD)<br>
<input type="hidden" name="RequireShippingSelection" value="true">
</div>
Run Code Online (Sandbox Code Playgroud)
我想遍历所有<inputs>并找到任何<sup>TM</sup>标签并从value现场删除它们.
我相信我需要使用这个.each()功能.只是不确定在每个函数中使用什么函数
$('#pnlCartAllowsShippingMethodSelection input").each(function() {
$(this).
});
Run Code Online (Sandbox Code Playgroud)
你可以使用.remove():
$('#pnlCartAllowsShippingMethodSelection sup').remove();
Run Code Online (Sandbox Code Playgroud)
对于单选按钮,您可以执行以下操作:
$('#pnlCartAllowsShippingMethodSelection input').val(function(index, value) {
return value.replace(/<sup>TM<\/sup>/g, '');
});
Run Code Online (Sandbox Code Playgroud)