javascript - how do i save return values from a .each call into an array -
i have function call:
createnode(e,control);// return id. // e leave alone, thinking // pass object function way optionally. function createnode(e, control){ if(!control) control = this; // rest of function, calls object $(control) instead of $(this). //... } i have selector want iterate over:
$(control_group).each(createnode); is there way build list of ids this, such as:
var arr = []; arr.push($(control_group).each(createnode)); i doing recurive control builder makes controls in controls, , want return identifiers child attribute. going arr.
my 1 idea doing simple like:
var arr = []; $(control_group).each(function(e){ arr.push(createnode(e,$(this)); });
that's .map() does:
var arr = $(control_group).map(createnode).get(); .map() returns jquery object; if want ordinary array, need .get() it.
Comments
Post a Comment