locked
how to put object to the array dynamically RRS feed

  • Question

  • User-1634604574 posted

    var result = [];

    $("input[class^='chk_colour']:checked").each(function (index, el) {

    var color = $(el).val();
    var size = "";
    var weight = "";
    $("input[class^='chk_size']:checked").each(function (index, el) {
    size = $(el).val();
    $("input[class^='chk_weight']:checked").each(function (index, el) {
    weight = $(el).val();


    })
    });
    });

    i want to write this code

    var d = [color, size, weight]

    for (var i = 0; i < d.length; i++) {
     result.push( d[i] );
    }

    but is not working

    instead this line

    result.push({ color, size, weight });

    Thursday, January 24, 2019 7:09 PM

All replies