On the basket page of my client's WooCommerce site is a series of HTML strings that are generated from meta data that I cannot edit and therefore wish to manipulate with jQuery.
Essentially, I want to make text prettier for better usability.
Current output:
BBQ Pack – Disposable×2 ( £10.00 - One Time ) ,
Desired output:
BBQ Pack – Disposable × 2 (£10.00 - One Time)
Mark-up:
<dd class="variation-Extras">
<p>BBQ Pack – Disposable×2 (
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">£</span>10.00
</span> - One Time ) ,
<br> Bike Pack – Electric×1 (
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">£</span>15.00
</span> - Per Day ) ,
</p>
</dd>
The below jQuery throws an error of .trim is not a function:
<script>
jQuery(document).ready(function(UpdateCartItemText) {
jQuery(".variation-Extras p").trim();
});
</script>
Any advide on why this isn't working and how to achieve the desired outcome of spaces either side of 'x' removing spaces before and after '(' and ')' and removing the end ',' would be great!
question from:
https://stackoverflow.com/questions/65865939/strip-spaces-on-one-condition-add-them-on-another-jquery-not-working 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…