After analyzing the table below:
<table id="cart-subtotals" cellspacing="0" class="shop_table
shop_table_responsive">
<tbody>
<tr class="cart-subtotal">
<th>Subtotal</th>
<td data-title="Subtotal"><span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">£</span>165</span></td>
</tr>
<tr class="shipping">
<th>Shipping</th>
<td data-title="Shipping"> Standard Delivery: <span class="woocommerce-
Price-amount amount"><span class="woocommerce-Price-
currencySymbol">£</span>9</span> <input type="hidden"
name="shipping_method[0]" data-index="0" id="shipping_method_0"
value="flat_rate:2" class="shipping_method"></td>
</tr>
<tr class="order-total">
<th>Total</th>
<td data-title="Total"><strong><span class="woocommerce-Price-amount
amount"><span class="woocommerce-Price-currencySymbol">£</span>174</span>
</strong> <small class="includes_tax">(includes <span class="woocommerce-
Price-amount amount"><span class="woocommerce-Price-
currencySymbol">£</span>7.86</span> Reduced Rate, <span
class="woocommerce-Price-amount amount"><span class="woocommerce-Price-
currencySymbol">£</span>1.50</span> VAT)</small></td>
</tr>
</tbody>
</table>
I am seeking a method to retrieve only the number '165' (without the currency symbol) from the first column in the table.
Although my attempt failed:
function() {
var element = document.querySelector('#cart-subtotal td:first');
var price = element.innerHTML.match(/\d*\.\d*/)[0];
return price;
}
Do you have any alternative suggestions?