How to remove some part of data from a variable
This is my jsfiddle
When once clicked on submit , i want to remove this part of text
'<p class="tcPriceWrap">25</p>'
So that i can have toppings array with only these values
Honey with Chocolate Sauce 10 ML
Honey with Carmel 10 ML
The below is the HTML
<div class="prd-items-detials">
<div style="display: block;" class="Topping-details" id="4">
<section id="topping_tsection_4">
<aside>
<h6 class="tdHeading">Quantity 1</h6>
<section class="secclass">
<a data-id="4" topping_id="1" id="4_ZZ_0_ZZ_0" topp_name="Honey with Chocolate Sauce 10 ML" top_price="25" class="tpActive">
Honey with Chocolate Sauce 10 ML
<p class="tcPriceWrap">25</p>
</a>
</section>
<section class="secclass">
<a data-id="4" topping_id="2" id="4_ZZ_0_ZZ_1" topp_name="Honey with Carmel 10 ML" top_price="25" class="tpActive">
Honey with Carmel 10 ML
<p class="tcPriceWrap">25</p>
</a>
</section>
</aside>
</section>
</div>
<input type="button" id="someid" value="Submit"/>
</div>
This is my javascript
var toppings = [];
$(document).on("click", "#someid", function(e) {
$("#topping_tsection_4").find('.tdHeading').each(function () {
values = [];
$(this).parent().find('.tpActive').each(function () {
alert($(this).text().trim());
values.push($(this).text().trim());
});
if(values.length>0)
{
toppings.push({
'name': $(this).text().trim(),
'value': values
});
}
});
}); // close of save event listener
$('.tcPriceWrap').remove()?