Story: I need to store JQuery('') into an array for further work.

My semi-functinal solution (not working properly):

```
    var myArray = new Array();
    var $selected_place;

    function addPlace(){
        var new_place = jQuery('<div/>', {
            class: 'place'
        });

        new_place.click(function(){
             doSomething($(this));
        });

        myArray[myArray.length] = new_place;
    }

```

The problem:

```
function doSomething(link) {
    var number;
    for (var i = 0; i < myArray.length; i++){
        if (myArray[i] == link){
            number= i;
            break;
        } //end of if
    } //end of for
    alert(number);
} //end of function

```

The alert always returns only 'undefined'.

THE SOLUTION:

Replacing the $(this) for a global variable solved my problem, now its working properly.
 $selected\_place = new\_place;
and in the doSomething method/function the if statement
 myArray[i] == $selected\_place