Jquery multidimensional array not working -
i'm trying multidimensional array in jquery.
var exclude_array = {}; $(this).siblings("tr[data-id='" + id + "']").each(function() { var id = $(this).attr("data-id"); var item_id = $(this).children("td:eq(3)").find("input[name='exclude']").attr("data-item_id"); exclude_array[id][] = item_id; });
i error uncaught syntaxerror: unexpected token ]
, exclude_array[id][]
how solve?
it seems you're trying push
item_id
exclude_array
. array[]
syntax not used in javascript. instead, must use .push()
.
before that, make sure key defined , array.
if (exclude_array[id] === undefined) exclude_array[id] = []; exclude_array[id].push(item_id);
Comments
Post a Comment