1$('select').on('change', function (e) {
2 var optionSelected = $("option:selected", this);
3 var valueSelected = this.value;
4 ....
5});
1<select class="form-control calculate" id="size" name="size">
2 <option data-price="5.00" value="Small">Small</option>
3 <option data-price="10.00" value="Medium">Medium</option>
4 <option data-price="15.00" value="Large">Large</option>
5</select>
6
7<span id="item-price">00</span>
8
9<script type="text/javascript" src="jquery-1.11.0.js"></script>
10<script type="text/javascript">
11var basePrice = 0;
12
13$(".calculate").change(function () {
14 newPrice = basePrice;
15 $(".calculate option:selected").each(function () {
16 newPrice += parseFloat($(this).data('price'));
17 console.log(typeof newPrice);
18 });
19 newPrice = newPrice.toFixed(2);
20 $("#item-price").html(newPrice);
21});
22</script>