I'm trying to add the values when a certain checkbox is selected, but it only adds the very first and ignores the next checkbox selected. For example, I selected Cheese and then Bacon, it only adds Cheese and Bacon's value is ignored.
var total = 0;
if ($("input:checkbox[name='extras']:checked").val() == "Cheese") {
total += 1.50 * 1;
} else if ($("input:checkbox[name='extras']:checked").val() == "Pepperoni") {
total += 1.50 * 1;
} else if ($("input:checkbox[name='extras']:checked").val() == "Mushrooms") {
total += 1.50 * 1;
} else if ($("input:checkbox[name='extras']:checked").val() == "Bacon") {
total += 1.50 * 1;
} else if ($("input:checkbox[name='extras']:checked").val() == "Olives") {
total += 1.50 * 1;
}
$("#ttl").html("Total Charge: $" + total);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="extras" value="Cheese">Cheese
<br>
<input type="checkbox" name="extras" value="Pepperoni">Pepperoni
<br>
<input type="checkbox" name="extras" value="Mushrooms">Mushrooms
<br>
<input type="checkbox" name="extras" value="Bacon">Bacon
<br>
<input type="checkbox" name="extras" value="Olives">Olives
<br>
<br><span id="ttl"></span>