push array to array jquery code example
Example 1: add value to array javascript
var fruits = ["222", "vvvv", "eee", "eeee"];
fruits.push("Kiwi");
Example 2: jquery add element to array
var ids = [];
$(document).ready(function($) {
var $div = $("").appendTo(document.body), code;
$(".color_cell").each(function() {
code = $(this).attr('id');
ids.push(code);
$div.append(code + "
");
});
});
Example 3: javascript append to array
arr = [1, 2, 3, 4]
arr.push(5) // adds element to end
arr.unshift(0) // adds element to beginning