how to add an element to an array in javascript? code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Example 2: jquery add element to array
var ids = [];
$(document).ready(function($) {
var $div = $("<div id='hexCodes'></div>").appendTo(document.body), code;
$(".color_cell").each(function() {
code = $(this).attr('id');
ids.push(code);
$div.append(code + "<br />");
});
});