How to sum multiple select options?

Suppose you have more than 1 select option, and you want to add the value or price of all the selected option which you have select. How to achieve it ? To perform this task, just use the simple method of JS which has been given below.

Foremost create select option as you want then add the below JS in script tag.
<script>
 var sum_select = 0;
    $('select :selected').each(function() {
        sum_select += Number($(this).attr('price'));
    });

</script>
In the above method we add the price, you can also use “value” instead of price or any those attribute which you want to add.