Jon Harding
Jon Harding

Reputation: 4946

jquery remove html in radio button value

I have a radio button list that gets dynamically generated by an XML feed from USPS an example below:

<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">&nbsp;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">&nbsp;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">&nbsp;First-Class Package International Service<sup>™</sup>** $19.53 (USD)<br>
    <input type="hidden" name="RequireShippingSelection" value="true">
</div>

I'd like to loop through all <inputs> and find any <sup>TM</sup> tags and remove them from the value field.

I believe I'd need to use the .each() function. Just not sure what function to use inside the each function

$('#pnlCartAllowsShippingMethodSelection input").each(function() {
    $(this).
});

Upvotes: 0

Views: 381

Answers (2)

cEz
cEz

Reputation: 5062

$('#pnlCartAllowsShippingMethodSelection sup").remove()

Upvotes: 1

Blender
Blender

Reputation: 298246

You can use .remove():

$('#pnlCartAllowsShippingMethodSelection sup').remove();

For the radio buttons, you could do something like this:

$('#pnlCartAllowsShippingMethodSelection input').val(function(index, value) {
    return value.replace(/<sup>TM<\/sup>/g, '');
});

Upvotes: 5

Related Questions