I have some HTML I’m working on using programming from a CMS I didn’t write and it’s outputting some HTML radio options and is repeating them. Unfortunately I can’t control the output of this programming, so I’m attempting an alternative route of just trying to only allow 1 instance of the HTML to show up. Here’s an example:
<label class="fc_radio" for="shipping_service_101"><input type="radio" name="shipping_service" id="shipping_service_101" value="101|45" class="fc_radio fc_required"><span class="fc_shipping_carrier">USPS International Shipping Rate (tracking included)</span> <span class="fc_shipping_cost"><span class="fc_currency_symbol">$</span>45</span> </label>
<label class="fc_radio" for="shipping_service_101"><input type="radio" name="shipping_service" id="shipping_service_101" value="101|45" class="fc_radio fc_required"><span class="fc_shipping_carrier">USPS International Shipping Rate (tracking included)</span> <span class="fc_shipping_cost"><span class="fc_currency_symbol">$</span>45</span> </label>
As you can see, it’s identical code. Is there anyway with jQuery to essentially filter out the extra HTML that’s being outputted and keep 1 instance of the HTML inside the ? They’re inside a div with this ID and Class:
<div id="fc_shipping_methods_inner" class="fc_shipping_methods_inner">
REPEATING HTML HERE
</div>
If it is just one extra element, you can do this:
$('label.fc_radio').eq(1).remove();Example: http://jsfiddle.net/ZgLaU/
If it is more than one element, use
.slice()$('label.fc_radio').slice(1).remove();Example 2: http://jsfiddle.net/ZgLaU/1/