I have a list of order and if element is selected (checked) - it sums the value and shows the text of element that is selected. How to show text of selected elements and remove it when unchecked? Link to code pen.
And the js itself:
$(".price-of-package-element").change(function () {
var count = 0,
priceElement = $(".price-of-package-element");
for (var i = 0; priceElement[i]; ++i) {
if (priceElement[i].checked) {
var value = priceElement[i].value,
title = $(this).next().text();
count += Number(priceElement[i].value);
$('#text').append("<div>" + title + "</div>");
}
}
});