w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
I have created multiple dynamic select boxes in div with class=pricefield. I want to fetch all select boxes value in jQuery

Write:

get_sum();
$('.pricefield select').change(function () {
    get_sum();
});
function get_sum() {
    var sum = 0;
    $('.pricefield select').each(function () {
        sum += parseInt($(this).find("option:selected").val());
    });
    alert(sum);
}

DEMO here.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.