Q:

How to store multiple  tags click into an array using Javascript?

There are multiple images in my HTML file. When a users click them, their IDs should be populated.
There is no problem in getting those IDs.
How can we do the following stuff
1) Storing all these IDs in an array when user clicks on multiple images.

Ex : 
array = img01 ; array = img02 ; 
final array = img01|img02|img03|....... based on the number of clicks made by the user

2) Passing this array to an another function
This array should be passed to a OnClick() function 
3) The function to which the array was passed is a button click function which should not take any parameters.
Can anyone help me on how to accomplish this task using JQuery or JavaScript ?
Thanks
Sandy.

A:

Initialize an array:
var ids = [];

When you want to add an ID, utilize Array's push method:
ids.push(id);

Access it from a function:
function theOnClickFunction(){
    console.log(ids);
}

